Reply To: GREP for applying character style to phrase between …

Home Page / Forums / General InDesign Topics (CLOSED) / GREP for applying character style to phrase between … / Reply To: GREP for applying character style to phrase between …

#116588
Jeremy Howard
Participant

Hey there! What you are trying to do is very similar to the GREP string that you provided in your post. Here’s what you’re after:

(?<=,).*?(?=;)

A breakdown of the GREP string:

(?<=,) – this is a positive look-behind, that is saying that we only want to find characters that come directly after a comma and a space.

.*? – this is “zero or more characters” the reason that I opted for this instead of the “.+” is because “.*?” is what’s known as a non-greedy specifier. It will match the minimum amount of characters before it stops formatting. On the other hand, “.+” is a greedy specifier, it will match as much as it possibly can before it stops applying the formatting. This causes issues when you are trying to access small piece of text within a list.

(?=;) – this is a positive look-ahead. This is saying that we only want to format the text that comes before the semi-colon and lets the GREP string know where it should stop formatting characters.

This solution will work for single and multiple comma affiliations because it matches from the first “, ” through the “;”.

This article was last modified on May 17, 2019

Comments (0)

Loading comments...