2 Replies Latest reply on Dec 17, 2012 12:37 PM by Pickory

    grep -o in findGrep

    Pickory Level 3

      Hello,

       

      Is there an equivalent to grep -o in InDesigns findGrep.

       

      I am searching for a string and I want to include some context of the found string. Here is my search string

       

      app.findGrepPreferences.findWhat = ".{0,"+String ( contextLength ) +"}?" + search_text+".{0,"+String ( contextLength ) +"}";

       

      This seems to work well if the search_text does not appear in the context area either side of a find.

       

      Thanks.

       

      P.

        • 1. Re: grep -o in findGrep
          Peter Kahrel Adobe Community Professional & MVP

          That's what you would expect, isn't it? If you search for .{0,12}word.{0,12} and your text contains "words, my Lord, words", the second instance of 'word' is included in the first match, so you're not going to find that second instance.

           

          You can make the match stop at either the next instance or the number of specified characters, whichever comes first:

           

          .{0,12}word.{0,12}(?=word)

           

          But I don't think you can have both.

           

          Peter

          1 person found this helpful
          • 2. Re: grep -o in findGrep
            Pickory Level 3

            Hello Peter,

             

            But I want both!

             

            Your hint is very handy. At least it gives me some thing close to what I wanted.

             

            Thank you very much.

             

            All the best.

             

            P.