1 Reply Latest reply on Jun 3, 2012 2:16 AM by Peter Spier

    Find and replace help

    kenrou123 Level 1

      I am trying to find the text that between parenthisis but when I use this Grep \(.+\)

       

      (hello everyone) (hi there)

       

      it selct the whole paragraph

       

      I want to make it select every parenthisis Separately

       

      (hello everyone) (hi there)

       

      thanks in advance

       

        • 1. Re: Find and replace help
          Peter Spier Most Valuable Participant (Moderator)

          You can use \(.+?\) to make the expression "not greedy" so it will stop at the first closing parenthesis it finds.

           

          Peter Kahrel discusses exactly this search in his book (http://shop.oreilly.com/product/9780596802530.do) which is areal bargain at about $10. He suggests, \([^)]+\) will also work and is actually faster. This expression uses a "negative class" [^)] of everything that is not a ) so it finds the opeing parenthesis and continues until it finds a close. The first expression finds the open, then continues until it finds the last close, then backtracts to find the shortes grouping if there is more than one close in what is found.