2 Replies Latest reply on Jun 7, 2013 12:00 AM by Vamitul

    GREP find specific number

    dvandervelde

      I am trying to put together a GREP that will look through and find 7. thats the number seven followed by a point and then apply a style to the point and not the seven.

       

      Ex. if there is 17.99 the style would apply to the decimal in that case but not in this 14.99. I have managed to pull togetther some nice things with GREP but this one is illuding me for some reason. I have tried some many combonations i am probbibly missing something simple.

       

      Can some one help me out?

        • 1. Re: GREP find specific number
          Jump_Over Level 5

          Hi,

           

          Possitive lookbehind is what you need:

          app.findGrepPreferences.findWhat = "(?<=7)\\.";

           

          it means ==> find every "dot" which follows "7".

           

          so your code could be:

          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "(?<=7)\\.";
          app.changeGrepPreferences.appliedCharacterStyle = "yourDotStyle";
          app.activeDocument.changeGrep();
          app.findGrepPreferences = app.changeGrepPreferences = null;
          

           

          Jarek

          • 2. Re: GREP find specific number
            Vamitul Level 4

            actualy.. you should also use a lookahead, so you won't find stuff like: "See page 7."

             

            so the grep expression is: (?<=7)\.(?=\d)

            and for scripting, using peter's trick i learned a few days ago:

            /(?<=7)\.(?=\d)/.source