I'm trying to format a keyword(s) that comes after specific string. For example, I want to bold the words, "happy", "sad", and "angry", but only if they are preceded by "be" or "become". This is an example of what I expect to be bolded:

I am happy, but I will be angry soon. Though she is sad now, she will become happy.

I have tried to GREP it like this:


This seems to work on other programs but not Indesign. I could construct the arguments "be" and "become" separately like this: (?<=be)(happy|sad|angry)|(?<=become)(happy|sad|angry), but it's not feasible when there are a lot of strings I need to match.


3 Answers 3


try using the InDesign script “FindChangeByList.jsx”. Find out about it here:

InDesign: how to run multiple find/change queries at once

In your instance, after first adding the “bold” character style to your document, you would add these lines to the “FindChangeList.txt”, then run the script.

grep    {findWhat:"(?<=be.)(happy|sad|angry)"}  {appliedCharacterStyle:"bold"}  {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

grep    {findWhat:"(?<=become.)(happy|sad|angry)"}  {appliedCharacterStyle:"bold"}  {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

It doesn't work because a lookbehind assertion has to be fixed width. Use this instead:


\b for word boundary.

\s for space, instead of . (which matches any character).


As qorinthian mentions, the above expression will also match the target words if they are preceded by characters like "am". To overcome this issue we might use this:

  • Your proposal does not work, at least for Adobe Indesign for which the question is asked. The square brackets identifies a character set, so your implementation will also bold the first "happy" in the example sentence because it is preceded by the "m" of "I am". The goal is to bold ONLY when preceded by "be" or "become."
    – qorinthian
    Jan 5 at 1:36
  • @qorinthian, you are absolutely right, thank you! I edited my answer accordingly.
    – Farzan
    Jan 6 at 15:07

For the record, the following GREP expression will work exactly as intended. Both keywords require individual PositiveLookbehinds for Indesign to parse properly.

((?<=be )|(?<=become ))(happy|sad|angry)

NegativeLookbehinds use a different structure, as Indesign GREP parses each Lookbehind separately instead of as a group. For example, this expression will ensure that "happy", "sad", or "angry" are bolded if preceded by "be" or "become", but NOT if preceded by "won't be" or "doesn't become".

(?<!won't be )(?<!doesn't become )((?<=be )|(?<=become ))(happy|sad|angry)

Farzan's answer also works, but you can't use it for more complex targets (e.g. applying a different style to different key words that also come after "be" and "become").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.