ITextSearchService2.FindAllForReplace Method

Definition

Searches for all occurrences of the searchPattern and calculates all the corresponding replacement results for every match according to the replacePattern.

public:
 System::Collections::Generic::IEnumerable<Tuple<Microsoft::VisualStudio::Text::SnapshotSpan, System::String ^> ^> ^ FindAllForReplace(Microsoft::VisualStudio::Text::SnapshotSpan searchRange, System::String ^ searchPattern, System::String ^ replacePattern, Microsoft::VisualStudio::Text::Operations::FindOptions options);
public System.Collections.Generic.IEnumerable<Tuple<Microsoft.VisualStudio.Text.SnapshotSpan,string>> FindAllForReplace (Microsoft.VisualStudio.Text.SnapshotSpan searchRange, string searchPattern, string replacePattern, Microsoft.VisualStudio.Text.Operations.FindOptions options);
abstract member FindAllForReplace : Microsoft.VisualStudio.Text.SnapshotSpan * string * string * Microsoft.VisualStudio.Text.Operations.FindOptions -> seq<Microsoft.VisualStudio.Text.SnapshotSpan * string>
Public Function FindAllForReplace (searchRange As SnapshotSpan, searchPattern As String, replacePattern As String, options As FindOptions) As IEnumerable(Of Tuple(Of SnapshotSpan, String))

Parameters

searchRange
SnapshotSpan

The range of text to search in.

searchPattern
String

The pattern to search for.

replacePattern
String

The replace pattern to use for the operation.

options
FindOptions

The options to use while performing the search operation.

Returns

An IEnumerable<T> containing all matches found and their corresponding replacement values.

Remarks

The returned IEnumerable<T> will contain a collection of tuples indicating all the matches. Each Tuple will contain a SnapshotSpan referencing the location of the match and a String containing the calculated replacement text for the match.

If you are not using regular expressions then the calculated replacement text will always equal the replacePattern. In that scenario, you can use the FindAll(SnapshotSpan, String, FindOptions) method to only obtain the search results.

Applies to