4 Replies Latest reply on Jun 13, 2012 5:36 PM by Angusdog

    Problem with GREP search

    Angusdog Level 1

      I've got a GREP search which finds characters in imported XML <I> and </I> which surround text to make italic:

      //Find text with ^I^ and ^/I^ around it. ITALIC

      app.findGrepPreferences.findWhat = "(\\^I\\^)(.+)(\\^/I\\^)";

      app.changeGrepPreferences.changeTo = "$2";

      app.changeGrepPreferences.appliedCharacterStyle = "Italic";

      app.activeDocument.changeGrep(); 

       

      The problem is that if there's two blocks of text in the para with the codes around it, it finds the first code <I> and the last code </I> and makes all the text in between italic.

       

      So for example, "The <I>quick brown fox</I> jumps over the <I>lazy dog</I> as sample text"

      comes out as "The quick brown fox</I> jumps over the <I>lazy dog as sample text",

      and not "The quick brown fox jumps over the lazy dog as sample text".

       

      I'm hoping this has a simple fix, but disappointing as I thought I had it nailed!

       

      Thanks in advance for any assistance (as always).

       

      Simon.