Community
    • Login

    Find and replace everything between and including parentheses

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 28.5k Views
    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 SchneidermanL
      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
      • dailD
        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 SchneidermanL
          Laura Malt Schneiderman
          last edited by

          @dail said:

          (.+?)

          Genius! Thank you!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors