次の方法で共有


ITextSearchService2.FindForReplace Method

Definition

Searches for the next occurrence of the search pattern and returns the result of replacing the search pattern with the replacement pattern.

Overloads

FindForReplace(SnapshotPoint, String, String, FindOptions, String)

Searches for the next occurrence of searchPattern and sets expandedReplacePattern to the result of the text replacement.

FindForReplace(SnapshotSpan, String, String, FindOptions, String)

Searches for the next occurrence of searchPattern and sets expandedReplacePattern to the result of the text replacement.

Remarks

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.

FindForReplace(SnapshotPoint, String, String, FindOptions, String)

Searches for the next occurrence of searchPattern and sets expandedReplacePattern to the result of the text replacement.

public:
 Nullable<Microsoft::VisualStudio::Text::SnapshotSpan> FindForReplace(Microsoft::VisualStudio::Text::SnapshotPoint startingPosition, System::String ^ searchPattern, System::String ^ replacePattern, Microsoft::VisualStudio::Text::Operations::FindOptions options, [Runtime::InteropServices::Out] System::String ^ % expandedReplacePattern);
public Microsoft.VisualStudio.Text.SnapshotSpan? FindForReplace (Microsoft.VisualStudio.Text.SnapshotPoint startingPosition, string searchPattern, string replacePattern, Microsoft.VisualStudio.Text.Operations.FindOptions options, out string expandedReplacePattern);
abstract member FindForReplace : Microsoft.VisualStudio.Text.SnapshotPoint * string * string * Microsoft.VisualStudio.Text.Operations.FindOptions * string -> Nullable<Microsoft.VisualStudio.Text.SnapshotSpan>
Public Function FindForReplace (startingPosition As SnapshotPoint, searchPattern As String, replacePattern As String, options As FindOptions, ByRef expandedReplacePattern As String) As Nullable(Of SnapshotSpan)

Parameters

startingPosition
SnapshotPoint

The position from which search is started. The search will be performed on the ITextSnapshot to which this parameter belongs.

searchPattern
String

The pattern to look for.

replacePattern
String

The pattern to replace the found text with.

options
FindOptions

Options used to perform the search.

expandedReplacePattern
String

The result of the replacement. This output parameter will be useful when performing regular expression searches. Will be empty if no matches are found.

Returns

A SnapshotSpan pointing to the search result found. If no matches are found, null is returned.

Remarks

This function does not perform any edits. The consumers would need to create an ITextEdit to perform the actual text replacement if desired. This method is safe to be executed from any thread.

Note that expandedReplacePattern will always equal replacePattern if the search is not using regular expressions. In those scenarios you can utilize the more lightweight Find(SnapshotSpan, SnapshotPoint, String, FindOptions).

Applies to

FindForReplace(SnapshotSpan, String, String, FindOptions, String)

Searches for the next occurrence of searchPattern and sets expandedReplacePattern to the result of the text replacement.

public:
 Nullable<Microsoft::VisualStudio::Text::SnapshotSpan> FindForReplace(Microsoft::VisualStudio::Text::SnapshotSpan searchRange, System::String ^ searchPattern, System::String ^ replacePattern, Microsoft::VisualStudio::Text::Operations::FindOptions options, [Runtime::InteropServices::Out] System::String ^ % expandedReplacePattern);
public Microsoft.VisualStudio.Text.SnapshotSpan? FindForReplace (Microsoft.VisualStudio.Text.SnapshotSpan searchRange, string searchPattern, string replacePattern, Microsoft.VisualStudio.Text.Operations.FindOptions options, out string expandedReplacePattern);
abstract member FindForReplace : Microsoft.VisualStudio.Text.SnapshotSpan * string * string * Microsoft.VisualStudio.Text.Operations.FindOptions * string -> Nullable<Microsoft.VisualStudio.Text.SnapshotSpan>
Public Function FindForReplace (searchRange As SnapshotSpan, searchPattern As String, replacePattern As String, options As FindOptions, ByRef expandedReplacePattern As String) As Nullable(Of SnapshotSpan)

Parameters

searchRange
SnapshotSpan

The range of text to search in.

searchPattern
String

The pattern to look for.

replacePattern
String

The pattern to replace the found text with.

options
FindOptions

Options used to perform the search.

expandedReplacePattern
String

The result of the replacement. This output parameter will be useful when performing regular expression searches. Will be empty if no matches are found.

Returns

A SnapshotSpan pointing to the search result found. If no matches are found, null is returned.

Remarks

This function does not perform any edits. The consumers would need to create an ITextEdit to perform the actual text replacement if desired. This method is safe to be executed from any thread.

Note that expandedReplacePattern will always equal replacePattern if search is not using regular expressions. In those scenarios you can utilize the more lightweight Find(SnapshotSpan, SnapshotPoint, String, FindOptions).

Applies to