Udostępnij za pośrednictwem


Metoda EditPoint2.ReplacePattern — (TextPoint, String, String, Int32, TextRanges%)

Wyszukuje deseń w określonym zakresie tekstu i zamienia określony tekst.

Przestrzeń nazw:  EnvDTE80
Zestaw:  EnvDTE80 (w EnvDTE80.dll)

Składnia

'Deklaracja
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

Parametry

  • Point
    Typ: EnvDTE.TextPoint
    Wymagane.Punkt końcowy określony zakres tekstu.Edytowany punkt i Point są granice dla zastąpienia.
  • Replace
    Typ: System.String
    Wymagane.Ciąg zastępujący dla Pattern.
  • Tags
    Typ: EnvDTE.TextRanges%
    Opcjonalne.Jeśli wzorzec dopasowanych jest wyrażenia regularnego, zawierające oznakowane sub-expressions, następnie Tags zawiera kolekcję TextRange obiektów, jeden dla każdego z oznakowanych wyrażenia podrzędnego.

Wartość zwracana

Typ: System.Boolean
true Jeśli zamiany pomyślnie; w przeciwnym razie false.

Uwagi

ReplacePatternWyszukuje tekst podobnie do FindPattern, z wyjątkiem, że tylko przeszukuje tekst między punktem Edycja i argument Point.Aby znaleźć i zamienić w całym dokumencie, należy użyć TextDocument.ReplacePattern.Tags Kolekcji zwraca tylko informacje o ostatnim dopasowaniu wzorca.

Przykłady

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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

EditPoint2 Interfejs

Przeciążenie ReplacePattern

Przestrzeń nazw EnvDTE80