Compartilhar via


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

'Declaration
Function FindForReplace ( _
    startingPosition As SnapshotPoint, _
    searchPattern As String, _
    replacePattern As String, _
    options As FindOptions, _
    <OutAttribute> ByRef expandedReplacePattern As String _
) As Nullable(Of SnapshotSpan)
Nullable<SnapshotSpan> FindForReplace(
    SnapshotPoint startingPosition,
    string searchPattern,
    string replacePattern,
    FindOptions options,
    out string expandedReplacePattern
)
Nullable<SnapshotSpan> FindForReplace(
    SnapshotPoint startingPosition, 
    String^ searchPattern, 
    String^ replacePattern, 
    FindOptions options, 
    [OutAttribute] String^% expandedReplacePattern
)
abstract FindForReplace : 
        startingPosition:SnapshotPoint * 
        searchPattern:string * 
        replacePattern:string * 
        options:FindOptions * 
        expandedReplacePattern:string byref -> Nullable<SnapshotSpan> 
function FindForReplace(
    startingPosition : SnapshotPoint, 
    searchPattern : String, 
    replacePattern : String, 
    options : FindOptions, 
    expandedReplacePattern : String
) : Nullable<SnapshotSpan>

Parameters

  • searchPattern
    Type: String

    [in] The text pattern to search for.

  • replacePattern
    Type: String

    [in] The text pattern to replace the found text with.

  • expandedReplacePattern
    Type: 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: 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