다음을 통해 공유


EditPoint2.FindPattern Method

Finds a given matching pattern in the selected text.

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

Syntax

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

Parameters

  • Pattern
    Type: String

    Required. The text you want to find.

  • vsFindOptionsValue
    Type: Int32

    Optional. A vsFindOptions constant indicating the type of search to perform. The vsFindOptionsMatchInHiddenText constant value does not apply to this method because FindPattern searches all text, including hidden text.

  • EndPoint
    Type: EnvDTE.EditPoint%

    Optional. An EditPoint object representing the point that is to be moved to the end of the matched pattern.

  • Tags
    Type: EnvDTE.TextRanges%

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

Return Value

Type: Boolean
true if the pattern is found; otherwise, false.

Remarks

FindPattern searches all text (including hidden) for the given text pattern from the edit point to the end of the document. One flag controls whether 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 endpoint 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 sub-expressions, then the Tags argument returns a collection of TextRange objects, one for each tagged sub-expression.

Examples

Sub FindPatternExample()
   Dim objTextDoc As TextDocument
   Dim objEditPt As EditPoint, iCtr As Integer
        
   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")
       
   ' Get a handle to the new document and create an EditPoint.
   objTextDoc = DTE.ActiveDocument.Object("TextDocument")
   objEditPt = objTextDoc.StartPoint.CreateEditPoint
        
   ' Insert ten lines of text.
   For iCtr = 1 To 10
      objeditpt.Insert("This is a test." & Chr(13))
   Next iCtr
   objEditPt.StartOfDocument()
   'Search for the word "test."
   If objeditpt.FindPattern("test") = True Then
      msgbox("Found the word.")
   End If
End Sub

.NET Framework Security

See Also

Reference

EditPoint2 Interface

EnvDTE80 Namespace