Compartir a través de


EditPoint.ReplacePattern (Método)

Busca un patrón en el intervalo de texto seleccionado y lo reemplaza por el texto especificado.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

'Declaración
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

    Obligatorio. Extremo del intervalo de texto especificado. El punto de edición y el correspondiente al parámetro Point son los límites del intervalo que se va a reemplazar.

  • Pattern
    Tipo: String

    Obligatorio. Cadena que se va a buscar.

  • Replace
    Tipo: String

    Obligatorio. Cadena de reemplazo correspondiente a Pattern.

  • vsFindOptionsValue
    Tipo: Int32

    Opcional. Constante vsFindOptions que indica el tipo de búsqueda que se va a realizar.

  • Tags
    Tipo: EnvDTE.TextRanges%

    Opcional. Si el modelo coincidente es una expresión regular que contiene subexpresiones etiquetadas, Tags contiene una colección de objetos TextRange, uno para cada subexpresión etiquetada.

Valor devuelto

Tipo: Boolean
true si el reemplazo se realiza correctamente; de lo contrario, false.

Comentarios

ReplacePattern busca texto de manera similar a FindPattern, excepto que sólo busca el texto entre el punto de edición y el argumento Point. Para buscar y reemplazar texto en el todo el documento, utilice ReplacePattern. La colección de Tags sólo devuelve información para el último modelo encontrado.

Ejemplos

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

Seguridad de .NET Framework

Vea también

Referencia

EditPoint Interfaz

EnvDTE (Espacio de nombres)