ITextSearchService2::FindForReplace Method (SnapshotSpan, String^, String^, FindOptions, String^)
Searches for the next occurrence of the search pattern and returns the result of replacing the search pattern with the replacement pattern.
Assembly: Microsoft.VisualStudio.Text.Logic (in Microsoft.VisualStudio.Text.Logic.dll)
Nullable<SnapshotSpan> FindForReplace( SnapshotSpan searchRange, String^ searchPattern, String^ replacePattern, FindOptions options, [OutAttribute] String^% expandedReplacePattern )
Parameters
- searchRange
-
Type:
Microsoft.VisualStudio.Text::SnapshotSpan
[in] The range of text to search in.
- searchPattern
-
Type:
System::String^
[in] The text pattern to search for.
- replacePattern
-
Type:
System::String^
[in] The text pattern to replace the found text with.
- options
-
Type:
Microsoft.VisualStudio.Text.Operations::FindOptions
[in] Options to use for the search.
- expandedReplacePattern
-
Type:
System::String^
[out] The result of the replacement. Value is null if no matches are found. This value will be useful when performing regular expression searches.
Return Value
Type: System::Nullable<SnapshotSpan>Returns the search result found. If no match is found, returns null.
This method does not perform actual edits. Consumers must create an ITextEdit to perform actual text replacement. This method is safe to execute on any thread.
Note that expandedReplacePattern will always equal replacePattern if the search is not using regular expressions. In those scenarios, you can use the more lightweight Find.