Search code examples
layoutadobe-indesign

Indesign GREP - How to find multiple words but change only one


Hyellooo! I am working on a project and hit a road block. I am looking to find a phrase "write true" in a text using grep, which is super easy, but my problem is I need to only italicize the word "true" and not "write". The reason I need to find it only when it follows the word "write" is because those are the only times that it needs to be italics, any other times it appears it will just stay normal. So I can find "write true" but then the grep italicizes both of the words. I need to find both words but protect the word "write" from being italic. Does this make sense? Hmm. Thanks for any help!


Solution

  • Try (?<=write )true

    enter image description here

    Positive Lookbehind (?<=write )true to find and modify all 'true' after 'write ' ('write ' will stay intact).

    Positive Lookahead write(?= true) to find and modify all 'write' before ' true' (' true' will stay intact)

    There are Negative Lookbehind (?!<=) and Negative Lookahed (?!=) as well. Just to keep us from getting bored. They search the word if it has no another word behind or ahead.