• Login
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.
  • L
    Laura Malt Schneiderman
    last edited by Feb 15, 2017, 3:27 PM

    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
    • D
      dail
      last edited by dail Feb 15, 2017, 4:40 PM Feb 15, 2017, 4:33 PM

      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
      • L
        Laura Malt Schneiderman
        last edited by Feb 15, 2017, 5:01 PM

        @dail said:

        (.+?)

        Genius! Thank you!

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