Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Find and replace everything between and including parentheses

    General Discussion
    2
    3
    24008
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Laura Malt Schneiderman
      Laura Malt Schneiderman last edited by

      I’m having some trouble with find and replace. I want to find and replace everything between and including parentheses. I have many instances of dollar amounts in between parentheses that I want to get rid of. I also have words between parentheses that I want to get rid of. Example: ($76,800), (N/A)

      I select Search > Replace. In “Find What” I put:
      ( .+)

      In “Replace With” I put nothing.

      I click “Replace All”. Notepad++ tells me that 0 occurrences were found. What am I doing wrong please?

      1 Reply Last reply Reply Quote 0
      • dail
        dail last edited by dail

        Parenthesis have special meaning to regular expressions. You need to escape them (by putting \ in front of them). So your regex would look like:

        \(.+\)
        

        Also, for safety you probably want to do lazy matching:

        \(.+?\)
        
        1 Reply Last reply Reply Quote 1
        • Laura Malt Schneiderman
          Laura Malt Schneiderman last edited by

          @dail said:

          (.+?)

          Genius! Thank you!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors