visual studio find / replace regular expressions

Posted on 2006-03-27
Last Modified: 2011-09-20

in the find/replace box for visual studio you can use regular expressions. i had a go with it but i think regular expressions in vb might eb slightly different than perl.

how do i write a regular expression for use in this dialogue that can remember the matched text.

For example, lets say i had this text:

ssss hello everyone ssss

and i wanted to replace it with

aaaa hello everyone aaaa

how would i do that? i need to remember the "hello everyone" bit

Thanks very much
Question by:andieje
    LVL 62

    Expert Comment

    by:Fernando Soto
    Hi andieje;

    Here is a link to the documentation for Visual Studio Regular Expression used in the IDE find/replace'

    In your example you want to replace the ssss in "ssss hello everyone ssss" With aaaa.

    Then do the following in the Replace dialog box:
    Find What: = <s^4>
    Replace With: = aaaa


    Author Comment

    I'm sorry, i posted late last night and was being a bit thick

    What i need to be able to do is this....

    hello everyone aaaa


    aaaa hello everyone aaaa

    I need to really insert some text around existing text
    LVL 62

    Accepted Solution

    New example:

    From this:

    hello everyone aaaa

    To this:

    aaaa hello everyone aaaa

    Then do the following in the Replace dialog box:
    Find What: = {<hello everyone>} {<a^4>}
    Replace With: = \2 \1 \2

    Author Comment

    Marvellous - that was what i was looking for!

    Thanks a lot

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now