次の方法で共有


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.

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

Syntax

'宣言
Function FindForReplace ( _
    searchRange As SnapshotSpan, _
    searchPattern As String, _
    replacePattern As String, _
    options As FindOptions, _
    <OutAttribute> ByRef expandedReplacePattern As String _
) As Nullable(Of SnapshotSpan)
Nullable<SnapshotSpan> FindForReplace(
    SnapshotSpan searchRange,
    string searchPattern,
    string replacePattern,
    FindOptions options,
    out string expandedReplacePattern
)
Nullable<SnapshotSpan> FindForReplace(
    SnapshotSpan searchRange, 
    String^ searchPattern, 
    String^ replacePattern, 
    FindOptions options, 
    [OutAttribute] String^% expandedReplacePattern
)
abstract FindForReplace : 
        searchRange:SnapshotSpan * 
        searchPattern:string * 
        replacePattern:string * 
        options:FindOptions * 
        expandedReplacePattern:string byref -> Nullable<SnapshotSpan> 
function FindForReplace(
    searchRange : SnapshotSpan, 
    searchPattern : String, 
    replacePattern : String, 
    options : FindOptions, 
    expandedReplacePattern : String
) : Nullable<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