Creating an automated star rating with GREP in InDesign

Maksim Goffin
3 min readAug 17, 2017

--

Recently I had to make a movie magazine in just a few days. To speed up work I used GREP to automate the star ratings at the end of each movie title. For example: (4 stars) had to become ★★★★☆.

Screenshot of the final result

The word stars consists of 5 letters. These letters can be used to make the 5 stars. To distinguish between a full and an empty star, the letters are placed in upper- or lowercase based on the rating. For example: (4 stars) becomes (4 STARs).

To achieve this make 2 Character Styles called ‘Star’ and ‘Empty Star’. Open ‘Star’, go to basic character formats>case and set to All caps. Leave ‘Empty Star’ temporary untouched.

For the movie titles create a Paragraph Style ‘Movie Title’. Now you need to add some GREP Styles. First, place all the letters from stars in the Character Style ‘Empty Star’. This can be done with GREP expression: (?<=\((1|2|3|4|5) )stars(?=\)). Then add all the expressions for the Character Style ‘Star’ to make relevant letters uppercase. For example: (?<=\(4 )star(?=s\)) is the GREP expression used to make (4 STARs).

To remove the brackets and numbers, create a new Character Style ‘blank’ with a 0.1 pt size, a horizontal scale of 1% and no character color. In the Paragraph Style ‘Movie Title’ add the following 2 GREP expressions: \((1|2|3|4|5)(?= stars\)) and (?<=stars)\). (4 stars) will now look like STARs.

In Fontforge I made a font Moviestars. In this font, the letters S, T, A, R are represented with ★ and s, t, a, r with ☆. Change the Font family in Character Styles ‘Star’ and ‘Empty Star’ to Moviestars to get the final result. (4 stars) will be displayed as ★★★★☆.

Finally, add some extra styling to the stars.

Download Moviestars or the InDesign Package.
Visit InDesignSecrets to learn more about GREP.

--

--