Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
GREP is a way to do sophisticated searches throughout your text. For example, let's say you want to find two or more spaces, regular spaces, Em spaces, Thin spaces, whatever, and then you want to change them all into a single space. Now you know you can open the Find Change dialog box by pressing Command+F or Ctrl+F on Windows, but what are you going to type here in the Find what field? This search is just too complicated for this simple field because we want to find all different kinds of spaces. Well fortunately, InDesign can do a GREP search for this. So I will click on the GREP tab and I will type in some codes for find all those different kinds of white spaces. Well in this case, I am going to start simple. I am not going to type the codes in myself, I am going to choose it from the Query popup menu, because Adobe was kind enough to give us the multiple space to single space query, and you can see that it actually types in all this code for me.
Now I am not going to get into the details of all the different kinds of things you can do with GREP, but I will tell you that these codes mean all the different spaces that you can type in InDesign, single regular space, and quarter spaces, and six spaces, and thin spaces and so on. And it just says, find anyone of those type of things, and then there is a thing over here in the curly braces, 2,, and that means find two or more of them in a row. Now what are we going to replace that with? Well, this \s. What does that mean? Well that is the special GREP code for a regular plain old space. So find two or more of a bunch of different kinds of spaces and replace that with a regular space. Let's try it out. Click Change All. It found three of them. Those are three that would have been difficult for me to find manually, then click OK, and we are done.
Now GREP seems scary at first, but if you take it slow, it's really not that hard. Let me delete that, and I will delete this and let's build our own GREP code. Now I don't need to remember all the codes myself because of this little fly out menu, the one that has a little @ sign. I don't know why Adobe chosen @ sign, it makes no sense to me but that's what you need to look at, and I am going to search for all of the percentages in my document. Anything that's a percentage, could be 1%, or a 20%, or a 100%, so it might have one digit, two digits, three digits, I don't know, but all I know is that its one or more digits followed by a percentage sign.
So we need to find the code to do that. So I am going to go to that little fly out menu and we can see that I can choose among all these different kinds of symbols and spaces and so on. In this case, I want to find digits, any digit. So I am going to go down to the Wildcard fly out menu and choose Any Digit. So this is the code for Find any digit, but I need one or more of those. So how do I do that? I will go back to that fly out menu, go down to the Repeat submenu and I want to say, Find One or More of these, and I am going to say the Shortest Match, and I don't want to get in the technical details of why I say Shortest Match, but basically it's just the one or more digits in a little clump, basically a clump of those.
Now, I am going to search for the percentage sign. The percentage sign, I happen to know, is not any kind of special character, so I can just type the %, which on the US keyboard is just Shift+5. So it's going to find a percent. Now let's try it out. I will click Find, and I will move this out of the way so we can see what it's found. There it is, right down there. I will zoom in there, there it is. I found that 7%. Boom! Right there. Let's try another one. Find next, it found 85%. So the search is working, we type the code for one or more digits followed by a % sign. Pretty cool! We are getting more efficient here. Now that I am feeling a little bit more warmed up to GREP, let's try a really complex one. I am going to de-select that, come back to the Find Change dialog box here, and I am going to find any text inside parenthesis. Now I am going to change the formatting of any text that I find inside of parenthesis.
Okay, now how do we do that? Well, we know that the first character is going to be an open parenthesis, but we don't want to change that parenthesis sign, we just know that it's before the text that we do want to change. So we are going to use this wacky feature down here in the Match fly out menu, called Positive Lookbehind. That means I am positive that behind the text that I am looking for, there is a parenthesis. So I need to put that parenthesis in between the equal and that parenthesis right there, and I can't just type an open parenthesis because in GREP, some characters are special characters, and parenthesis is one of them.
So I need to go to the fly out menu and choose from the Symbols pop out menu, I am going to choose Open Parenthesis. So this means, find any text in which the character before the text is a parenthesis. Got it? Now, I need to find all those characters. It could be any kind of character. I don't know what it's going to be in there. It's not just digits, it's not just letters, it could be anything. So I will go to the flyout menu, I will choose Wildcards, and then I will choose Any Character. The symbol for that is a little dot or a period.
Now I need one or more of those. So I will go down here one more time to the Repeat fly out menu and choose One or More Times (Shortest Match). Find me a clump of characters that are inside parenthesis. We know that the character before is an open parenthesis, now we need to say the character after is going to be a closed parenthesis. So I will go back to say I want to find a Positive Lookahead, in other words the character after the text that I am finding here is going to be a parenthesis, and that one is going to be a symbol called the Closed Parenthesis character.
That was a lot of work, but it could save us a lot of time if it works. Now, what I said was I wanted to change the formatting of that text. So I am going to leave Change To blank. When you Find What and Leave Change to blank, it means find something but don't change it, as long as we have formatting down here. So I will click down in the Change Format area and I am going to -- let's say, I will just change the color of it. I will make it Magenta and why don't I change the fonts to something different like Myriad, Bold Italic, sure why not, Myriad Bold Italic.
Click OK, and now we are going to try it out to see if it works. I will click Find, and look at that, it found all the text inside parenthesis but not including the parenthesis themselves. Now I will click Change to see if to works. There you go. It applied the formatting to that text. Click Find next, and it found a bunch of text here. Change it, looks good, find it, change it, and so on, and of course I could use Change All or Find Change and you get the idea. So it found all of those throughout the entire document.
In the later chapter, I cover even more things that you can do with GREP. It's an incredibly powerful language for doing Find Change operations, and while that takes a bit of time to master, you more than make up for it in the time that you save down the road.
Get unlimited access to all courses for just $25/month.Become a member
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.