4 Replies Latest reply on Dec 13, 2013 8:41 AM by [Eric B]

    How to keep Character Styles applied to the right text when doing GREP find/replace?

    [Eric B]

      Hi,

       

      I'm having an issue with the GREP find/replace in InDesign 5.5.  I need to put bracket "[ ]" around text marked in "French: Canadian" language.

       

      I thought a basic GREP find/replace would do the trick, but it mess up the Character styles in it, by changing the position of where it is applied.

       

      Allow me to explain.

       

      Here are the parameters of my grep search.

       

      Find what: .*

      Change to: [$0]

      Find Format: + language: French: Canadian

       

      When I execute this, the character style applied to a text will get bumped by the numbers of characters that I added to the left of the $0 in the Change To param.  Meaning that, If I add more characters to the left of the string $0 in my Change To like so "MORE_CHARACTER[$0]", the character style will be moved by the number of character added before, in this case by 15 characters.

       

      So for example using this

       

      Find what: .*

      Change to: MORE_CHARACTER[$0]

      Find Format: + language: French: Canadian

       

      The text before will look like this

       

      This is a string that has a character styles on the first occurence of the word "has".

       

      The text after will look like this

       

      MORE_CHARACTER[This is a string that has a character styles on the first occurence of the word "has".]

       

      The character styles that was applyed is no longer applied to the first "has", but it is instead applied to the "ng " of the word "string" and the space after.

       

      Am I suppose to do the grep replace differently?