Compartilhar via


TextSelection.FindPattern Method

Searches for the given pattern from the active point to the end of the document.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Function FindPattern ( _
    Pattern As String, _
    vsFindOptionsValue As Integer, _
    <OutAttribute> ByRef Tags As TextRanges _
) As Boolean
bool FindPattern(
    string Pattern,
    int vsFindOptionsValue,
    out TextRanges Tags
)
bool FindPattern(
    [InAttribute] String^ Pattern, 
    [InAttribute] int vsFindOptionsValue, 
    [InAttribute] [OutAttribute] TextRanges^% Tags
)
abstract FindPattern : 
        Pattern:string * 
        vsFindOptionsValue:int * 
        Tags:TextRanges byref -> bool
function FindPattern(
    Pattern : String, 
    vsFindOptionsValue : int, 
    Tags : TextRanges
) : boolean

Parameters

  • Tags
    Type: EnvDTE.TextRanges%

    Optional. If the matched pattern is a regular expression containing tagged subexpressions, then the Tags argument contains a collection of TextRange objects, one for each tagged subexpression.

Return Value

Type: System.Boolean
A Boolean value indicating true if the pattern is found, false if not.

Remarks

FindPattern searches for the given text pattern from the edit point to the end of the document. One of the flags controls whether or not the search starts at the beginning of the document. The pattern may be a regular or other expression. The return value indicates whether the pattern is found. If the pattern is found, the edit point is moved to the beginning of the match. Otherwise, the edit location is unchanged.

If an end point is supplied and the pattern found, then FindPattern moves the endpoint to the end of the found pattern.

If the matched pattern is a regular expression and contains tagged subexpressions, then the Tags argument returns a collection of TextRange objects, one for each tagged subexpression.

Examples

Sub FindPatternExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection

   ' Advance to the next Visual Basic function beginning or end by 
   ' searching for  "Sub" with white space before and after it.
   If objSel.FindPattern(":WhSub:Wh", vsFindOptions.vsFindOptionsRegularExpression) Then
      ' Select the entire line.
      objSel.SelectLine()
   End If
End Sub

.NET Framework Security

See Also

Reference

TextSelection Interface

EnvDTE Namespace