EditPoint.ReplacePattern, méthode

Recherche un modèle de texte dans la plage de texte spécifiée et le remplace par le texte spécifié.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
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

Paramètres

  • Point
    Type : EnvDTE.TextPoint
    Obligatoire.Point de terminaison de la plage de texte spécifiée.Le point d'édition et Point délimitent le domaine de remplacement.
  • Pattern
    Type : System.String
    Obligatoire.Chaîne à rechercher.
  • Replace
    Type : System.String
    Obligatoire.Chaîne devant remplacer Pattern.
  • Tags
    Type : EnvDTE.TextRanges%
    Facultatif.Si le modèle trouvé est une expression régulière contenant des sous-expressions avec balises, Tags contient une collection d'objets TextRange, un pour chaque sous-expression avec balises.

Valeur de retour

Type : System.Boolean
true si le remplacement est réussi ; sinon false.

Notes

ReplacePattern recherche du texte comme FindPattern, mais seulement entre le point d'édition et l'argument Point. Pour rechercher et remplacer du texte dans l'ensemble du document, utilisez ReplacePattern. La collection Tags retourne uniquement les informations relatives au dernier modèle trouvé.

Exemples

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

Sécurité .NET Framework

Voir aussi

Référence

EditPoint Interface

EnvDTE, espace de noms