Viewers: in countries Watching now:
Learning GREP with InDesign decodes the language of GREP for InDesign users. It shows how this versatile tool can be used for describing text, which can speed up or automate everyday formatting tasks. InDesign expert and graphic designer Michael Murphy introduces the basic concepts of GREP, and shows how to build powerful expressions using metacharacters. Michael also explores many of the little-known features of GREP, explaining how GREP styles and Find/Change can be used to rearrange data and dynamically format text. Exercise files accompany this course.
The next metacharacter we're going to look at is grouped under the Match submenu. The options in this group are among the most powerful, complex, and abstract metacharacters you'll use when you work with GREP. They handle everything from imposing conditions on your expression, to isolating smaller parts of a larger expression, to defining a custom set of valid matching characters. We're going to start with the simplest of all of these, the Or metacharacter. I'm zoomed in on the top part of page 8 in this document and my cursor is within the body text.
So my Body Text style is highlighted in the Paragraph Styles panel. I'll right-click on the Style Name, choose Edit Body Text, and I am going to go to the GREP Style area to create a new GREP Style. From the Apply Style menu, I'm going to choose the existing character style, Red. That just highlights text and applies a red color to it. In the To Text field, by default, any digit one or more times is selected, but there's no effect on the page, that we can see, and I am just going to clear that right out. So now, I'm starting clean and I want to use the Or metacharacter in a practical situation.
What I want to actually describe is 'his', and then from the Special Character menu, go to Match>Or, which puts in the Vertical Slash character, also called the pipe. And on the other side of that, I'm going to type 'her'. So basically, I've written an expression that says his or her and applies a red color to any text that matches. Let's click off here, and you can see that's what happens on the page. I get the 'her' in the word 'there', also in the word 'there' here, but 'her' and 'his' as whole words, the 'his' in 'this', the 'his' in 'Whispered'.
So I've successfully matched his or her, but I haven't matched whole words. If I want to limit my results on the page to only instances of his or her that are whole words, and not have any partial word matches, I need to surround each word with a word boundary location metacharacter, which we've seen in a previous movie. So I'm going to go back and modify this expression. I'm going to put my cursor right at the beginning of the expression before the H in his, go to the Special Characters menu, down to Locations, and I am going to choose the Word Boundary location metacharacter.
That puts a \b before the h in His. I'm also going to put one at the end of the word, after the S, another one before the H in her, and after the R in Her, and I did that simply by copying the first word boundary metacharacter, and pasting it in where I needed it, throughout the expression. When I click off, you can see that I've successfully matched just a whole word His or Her in this document. I'm going to clear this out, and let's try another example, using the Or metacharacter.
On this page, there are a few Knights of the Round Table mentioned and I want to call out those names, also using the Red character style that's already selected here. In the To Text field, I'm going to just type in static text, the word Sir, and I'll type space and if I click off, you can see that highlighted on the page here before Sir Galahad, Sir Launcelot, Sir Kay, and in other places. If I wanted to highlight Sir Kay, or Sir Launcelot, or Sir Galahad, you might think that I could type in Sir Kay, go to the Special Characters menu, and choose the Match Metacharacter Or, and then just type Galahad, then another Or metacharacter and Launcelot( Sir Kay|Galahad|Launcelot).
So now I'm saying Sir Kay, or Galahad, or Launcelot. Let's see what happens when I click off on the page. Well, I've matched exactly what I've described, but it may not be what I intended. I wanted to highlight Sir Kay, Sir Galahad, and Sir Launcelot. But instead, I described Sir Kay, or Galahad, or Launcelot, without the Sir before them. The Or metacharacter considers everything that proceeds it to be one choice, everything that follows it to be another choice, and it goes as far as it has to go.
So it looks at Sir Kay as one thing, Galahad as another, and Launcelot. The Sir doesn't get appended to the other Knight names. So, this has to be described differently. So, one way to fix this is to go in to each part of this expression and add Sir and a space before each name. Now, each choice, this, or that, or the other is entirely specific. So if click off, it matches Sir Galahad, up here, Sir Launcelot, Sir Kay, and any other instances of that throughout the text.
The problem is this is not the most efficient way to do this. It's a little bit cumbersome. It takes a little bit longer, and it makes for a longer expression. One of the problems with working with GREP in InDesign is that you only have this amount of space in the field, either here in GREP Styles or in Find/Change, to type your full GREP expression. If the expression starts to get longer, it scrolls over, and it becomes a little bit more difficult to look at the whole thing at once, and work with it, towards the far end of the expression.
So we want to write this a little bit more efficiently, but in order to do that, we need to use something that's called a sub-expression, and we'll cover that in another movie.
Find answers to the most frequently asked questions about Learning GREP with InDesign .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
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.