Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When text is 100% consistent, it's very easy to describe. Inconsistent text is a bit more challenging, but can also be described with GREP. In a previous movie, we set up a GREP style that automatically formatted figure references in a document, and it successfully formatted only the figure references that appear in parentheses, not the ones that didn't, but excluded the parentheses from the formatting, using Positive Lookbehind and Positive Lookahead. This is that document with that style applied. I am on page 4, and as I scroll down, I can see my styled Figure 11 reference, and down here later on the page, I see Figure 14 and Figure 15.
So something is missing. Something didn't get styled. I will scroll back up, and you can see here, Figures 12 and 15. They are not referred to in a consistent manner, as the other figures. Let's take a look at the Paragraph style itself, and the GREP style built into it to see what we've got so far. I'll choose Edit>Auto Figure References, and go to the GREP Style area for that style. And here's the expression we set up in the previous movie. Positive Lookbehind and Lookahead are at the beginning and end of the expression, and we refer to all of the figure references as Figure, space, any digit one or more times.
Well, this Figures 12 and 15 out here does not meet that criteria. It doesn't match, so it isn't styled. So I need to modify this GREP expression. So that I'll not only continue to style the figure references that I've already styled, but to account for this slightly different phrasing of figure references here, where I refer to more than one figure. The first thing I need to do is account for the presence of the plural version of 'figures'. That's easy enough to do by just putting an S at the end of the word Figure, then going to the Special Characters menu, and choosing the Repeat Metacharacter Zero or One Time.
This means the S may be there. It may not be there. Both are a match. And if I click off here, let's scroll back down to that. That has not yet fixed this, because it's only fixed one part, Figure and Figures, but what follows that is still not described in a way that handles both. So the thing you need to do when you're working out of GREP expression is to step back, and look at what it is you are trying to describe, not get too hung up on the specifics of the words themselves, and think about the pattern you're trying to describe.
So, in this instance, I'm trying to account for the word 'Figure' or 'Figures', which I've already done, followed by a space, followed by any digit one or more times. That gets me all the way through Figures, space 12, in this particular figure reference. I have to account for the possibility that another space, another word, another space, and another one or more digits could follow that before the closing parenthesis is encountered.
There are a couple of ways that I can do this. Some of them are very rigid and specific. Some of them are far more flexible. Let's start with what might be the natural inclination. After the any digit One or More Times Metacharacter, I could type in a space, the word 'and', another space, and another any digit one or more times metacharacter combination. If I enclose that in parentheses, making it a sub-expression, and then follow it with a question mark, meaning zero or more times, I've now made the presence of the word 'and', the spaces around it, and the additional number optional.
So I am going to click off here, and I'll see what that does. That solved the problem, but it solved the problem in a very, very specific way. So I am going to click OK here, and commit to this style. Let me make a change. Instead of 'and', at some point this document is edited, and it becomes an ampersand and my automatic styling breaks. My other styles still work. Figure 11, Figures 14 and 15, no problems there.
But I've been a little too rigid and not accounted for the fact that things change and maybe I should write an expression that's a little bit more flexible, and adaptable. So I am going to go back in and modify this style again. And in this GREP Style, I don't want to think specifically about the word 'And' and I want to cover my bases as much as possible. Suppose this was phrased as Figures 12 through 15, which it technically should be because figures 12 and 15 are nonconsecutive.
But if it was going to be Figures 12 through 15, or 12 em dash 15, however it's going to be phrased, I want to account for any possibility of that. So the 'And' is a little bit too specific for me. So I can get rid of that, and instead, I'm going to replace that with something more broad, and less specific. From the Special Characters menu, I'm going to choose the Wildcard, Any Character, and after that, the Repeat Metacharacter, One or More Times(Shortest Match), because technically, the numbers in the second figure reference also fall under the criteria of any character.
If I just use One or More Times, it's not going to differentiate, and it's going to go straight through to that closing parenthesis. So this makes things more specific and reins in that any character metacharacter. So I'll choose that, and it puts in a Plus sign and Question Mark, which is One or More Times(Shortest Match). I'll click off here, and there we have a successful match. Let's test out just how successful it is. Click OK. I'll select this ampersand, and instead, I'll type the word 'through', Figures 12 through 15. That also works.
If I get rid of the spaces around it altogether, and type in an em dash, Figures 12-15 also work. So, this works for many, many phrasings of a figure reference, and I have got a very flexible style that I can use that's going to account for all of them. So I've covered all the bases. All the figure references within parentheses are styled, but the parentheses around them are not, and in those instances, where the wording of those references varies from most of the others, we've allowed for that using the Zero or One Times Metacharacter, and making certain parts of the expression optional.
Get unlimited access to all courses for just $25/month.Become a member
117 Video lessons · 42874 Viewers
119 Video lessons · 54221 Viewers
65 Video lessons · 14474 Viewers
113 Video lessons · 82883 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.