共用方式為


TextSelection.FindPattern 方法

從作用點到文件結尾搜尋指定的模式比對。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
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

參數

  • Pattern
    型別:System.String
    必要項。要尋找的文字。
  • Tags
    型別:EnvDTE.TextRanges%
    選擇項。如果符合的模式比對是規則運算式 (Regular Expression) 並且含有標記子運算式 (Subexpression),則 Tags 引數會包含 TextRange 物件的集合,每個物件都會對應到一個標記子運算式。

傳回值

型別:System.Boolean
如果找到該模式,布林值會表示為 true,否則為 false。

備註

FindPattern 會從編輯點到文件結尾,搜尋指定的文字模式比對。 其中一個旗標會控制是否要從文件的開頭開始。 模式比對可以是規則運算式或是其他運算式。 傳回的值會指出是否找到了模式比對。 找到模式比對時,編輯點會移動到符合位置的開頭。 否則,編輯位置將不會變更。

如果提供了結束點而且找到了模式比對,則 FindPattern 會將端點移至找到的模式比對結尾。

如果符合的模式比對是包含標記子運算式的規則運算式,則 Tags 引數會傳回 TextRange 物件的集合,其中每一個物件都會對應到一個標記子運算式。

範例

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 安全性

請參閱

參考

TextSelection 介面

EnvDTE 命名空間