閱讀英文

共用方式為


ITextSearchService2.FindForReplace Method (SnapshotPoint, 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.

Namespace:  Microsoft.VisualStudio.Text.Operations
Assembly:  Microsoft.VisualStudio.Text.Logic (in Microsoft.VisualStudio.Text.Logic.dll)

Syntax

'宣告
Function FindForReplace ( _
    startingPosition As SnapshotPoint, _
    searchPattern As String, _
    replacePattern As String, _
    options As FindOptions, _
    <OutAttribute> ByRef expandedReplacePattern As String _
) As Nullable(Of SnapshotSpan)

Parameters

  • 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.
  • 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 nulla null reference (Nothing in Visual Basic).

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.

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.

.NET Framework Security

See Also

Reference

ITextSearchService2 Interface

FindForReplace Overload

Microsoft.VisualStudio.Text.Operations Namespace