RegEx Search for finding and replacing Visual Studio Add-ons

I am looking for a Visual Studio Addon that performs a standard regular expression search and replace, rather than a Microsoft Visual Studio version of the regular expression

How do you not get the full syntax

Please, help?

thank

+3
source share
3 answers

You can always write a VB.Net macro to do this; depending on how flexible you want.

For search and replace in the current document, you can use this simple script - ALT + F11 to start the macro editor and then leave. Insert this subsection into the new module:

Sub RegexReplace()
    Dim regex As String = InputBox("Enter regex for text to find")
    Dim replace As String = InputBox("Enter replacement pattern")

    Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection
    Dim editPoint As EnvDTE.EditPoint

    selection.StartOfDocument()
    selection.EndOfDocument(True)

    DTE.UndoContext.Open("Custom regex replace")
    Try
        Dim content As String = selection.Text
        Dim result = System.Text.RegularExpressions.Regex.Replace(content, regex, replace)
        selection.Delete()
        selection.Collapse()
        Dim ed As EditPoint = selection.TopPoint.CreateEditPoint()
        ed.Insert(result)
    Catch ex As Exception

    Finally
        DTE.UndoContext.Close()
        DTE.StatusBar.Text = "Regex Find/Replace complete"
    End Try

End Sub

, VS "Macro Explorer"; , (, - !). .

, , find/replace, ; .

( !) " " , , !

;)

+2

Visual Studio 2008 .Net Regex: . .NET Visual Studio 2008.

+5

Please see here: Visual Studio Identifier and Regular Expressions

A free add-on is available that offers the search for real regular expressions in Visual Studio.

+3
source

Source: https://habr.com/ru/post/1728025/


All Articles