5 Replies Latest reply on Oct 12, 2012 1:15 AM by Kasyan Servetsky

    Problem with GREP — finds only the 1st occurrence

    Kasyan Servetsky Level 5

      Hi all,


      In the example below, I am trying to find text between pairs of $ characters.


      Theoretically this should work — \$\s.+?\s\$ — but in practice it finds only the 1st occurrence. I can’t figure out why.

      Interestingly enough, in JS this expression works as expected.
      I select the text and run the script:


      function Main() {
          var doc = app.activeDocument;
          var sel = app.selection[0];
          var contents = sel.contents;
          var match = contents.match(/\$\s.+?\s\$/g);


      And it returns all the four occurrences:


      What am I doing wrong?

      Thanks in advance.