Método EditPoint2.ReplacePattern (TextPoint, String, String, Int32, TextRanges%)

Localiza um padrão no intervalo especificado de texto e o substitui pelo texto especificado.

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

Sintaxe

'Declaração
Function ReplacePattern ( _
    Point As TextPoint, _
    Pattern As String, _
    Replace As String, _
    vsFindOptionsValue As Integer, _
    <OutAttribute> ByRef Tags As TextRanges _
) As Boolean
bool ReplacePattern(
    TextPoint Point,
    string Pattern,
    string Replace,
    int vsFindOptionsValue,
    out TextRanges Tags
)
bool ReplacePattern(
    [InAttribute] TextPoint^ Point, 
    [InAttribute] String^ Pattern, 
    [InAttribute] String^ Replace, 
    [InAttribute] int vsFindOptionsValue, 
    [InAttribute] [OutAttribute] TextRanges^% Tags
)
abstract ReplacePattern : 
        Point:TextPoint * 
        Pattern:string * 
        Replace:string * 
        vsFindOptionsValue:int * 
        Tags:TextRanges byref -> bool 
function ReplacePattern(
    Point : TextPoint, 
    Pattern : String, 
    Replace : String, 
    vsFindOptionsValue : int, 
    Tags : TextRanges
) : boolean

Parâmetros

  • Point
    Tipo: EnvDTE.TextPoint
    Obrigatório.O ponto de extremidade do intervalo especificado de texto.O ponto de edição e Point são os limites de substituição.
  • Pattern
    Tipo: System.String
    Obrigatório.A seqüência de caracteres para localizar.
  • Replace
    Tipo: System.String
    Obrigatório.A seqüência de caracteres de substituição para Pattern.
  • Tags
    Tipo: EnvDTE.TextRanges%
    Opcional.Se o padrão correspondente é uma expressão regular contendo subexpressões com marcas de formatação, em seguida, Tags contém uma coleção de TextRange objetos, um para cada subexpressão com marcas de formatação.

Valor de retorno

Tipo: System.Boolean
true Se a substituição ocorre com êxito; Caso contrário, false.

Comentários

ReplacePatternLocaliza o texto da mesma forma FindPattern, exceto que ele pesquisa somente o texto entre o ponto de edição e o argumento Point.Para localizar e substituir no documento inteiro, use TextDocument.ReplacePattern.O Tags coleção retorna apenas informações para o último padrão correspondente.

Exemplos

Sub ReplacePatternExample()
   Dim objTextDoc As TextDocument
   Dim objMovePt As EditPoint
   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")
   objMovePt = objTextDoc.EndPoint.CreateEditPoint
   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()
   objMovePt.EndOfDocument()
   ' Replace all occurrences of "test" with "thing."
    objEditPt.ReplacePattern(objMovePt, "test", "thing", vsFindOptions.vsFindOptionsFromStart)
End Sub

Segurança do .NET Framework

Consulte também

Referência

EditPoint2 Interface

Sobrecargas ReplacePattern

Namespace EnvDTE80