Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

GREP Basics: How to Use Code to Find Specific Text

1. GREP basics: Using codes to find text provides you with in-depth training on Design. Taught by Da… Show More

InDesign: 10 Things to Know About GREP

with David Blatner

Video: GREP Basics: How to Use Code to Find Specific Text

1. GREP basics: Using codes to find text provides you with in-depth training on Design. Taught by David Blatner as part of the InDesign: 10 Things to Know About GREP
please wait ...
1. GREP basics: Using codes to find text
Video duration: 7m 24s 1h 8m Intermediate


1. GREP basics: Using codes to find text provides you with in-depth training on Design. Taught by David Blatner as part of the InDesign: 10 Things to Know About GREP


1. GREP basics: Using codes to find text

So GREP is all about finding patterns of text and you're already familiar with patterns of text. Like what's a bunch of letters all grouped together? Well, that's a word, right? Or what's a bunch of words all grouped together. Well, that's a sentence or maybe a paragraph. But you can't say to InDesign, find me a bunch of words all grouped together. Now you need to type in codes, GREP codes. That's what InDesign is expecting. So the good news is that those codes are either really simple or InDesign will actually type them for you. Now because we're searching for text the best place to go and do that is the Find/Change dialog box. I'll open the Find/Change dialog box by pressing Command+F or Ctrl+F on Windows and we'll see that there are actually four different dialog boxes in one here: Text, GREP, Glyph and Object. We're going to be focusing not on text, which is where most people do their work but instead on GREP.

So I'll click on GREP or you can press Command+2 or Ctrl+2 on Windows to jump to that second tab and I'm going to type my code into the Find What field. So I'm going to search for some kinds of chocolate. Let's say I'll search for a Milk chocolate and I'll click Find and it will jump right to the first instance of Milk chocolate. Let's see where is that, there it is, right in the text here. And I zoom in to 200% here. I'll click on the document and then go into 200% with a Command+2 or Ctrl+2 on Windows, and there is the text that I found Milk chocolate.

But in this case I want to find Milk chocolate or maybe Dark chocolate, one or the other. So let's go ahead and type in some codes for that. I'm going to type Dark here at the beginning and I want to tell InDesign to search for either Dark or Milk chocolate. So I'm going to add a vertical bar. On the US keyboard that's Shift+\, gets that vertical bar in between them. And I also need to put some parenthesis around this. So it's going to be Dark or Milk chocolate. That's our first code. Let's go and try it out. Find that and it finds Milk chocolate, Find again and it says it's completed.

Well I know there are some other instances of Dark chocolate and Milk chocolate in this document; it's a whole magazine about chocolate after all. So I need to find out why it's not working. So here is the key. GREP is case-sensitive. You always have to pay attention to the case of every character. So in this case it's looking for D, M and c, but if change that to a C and hit Find, now it will find it. It will find Milk Chocolate, click Find again, there is Milk Chocolate and there is Dark Chocolate. So it will find either Dark or Milk Chocolate.

Now if I want to tell that GREP code to search for lowercase or uppercase, I need to add a few more codes in here. So I'm going to put in some more characters. This is going to be either lowercase or uppercase d. Did you see that? I put in an open parenthesis and then a lowercase and then a vertical pipe and an uppercase d and then closed parenthesis, and I'll do the same thing here for the m, lowercase or uppercase m. And I'll do the same thing for the c. This is little bit more verbose than you need to be. There is more codes in here than you actually need, but it's a very easy way to see what's going on.

Dark chocolate, lowercase or uppercase, lowercase m or uppercase and lowercase or uppercase c. So now we have a lot of flexibility in here. It's going to be looking for Dark or Milk chocolate in uppercase or lowercase characters. Let's try it out. Find it, find it, find it. There we go. It's going to keep looking around and there we go. There is the Dark chocolate in lowercase. Both d and c are in lowercase here as well. I want to point out one little trick here that I need to warn you about. If I use the Option+Spacebar or Alt+Spacebar trick to use my grabber hand to try and scroll this over, I'm going to have a problem and that problem is that my GREP code will disappear. This always catches me. It's very, very frustrating.

For example I'll do Option+Spacebar and I'll start to be able to scroll around, but look what happened to my GREP code. It completely disappeared. That is very frustrating. Maybe it's a bug in InDesign, I don't know. But it actually typed a bunch of spaces here because the GREP code was selected. Fortunately there is a way to get those codes back. So if I click on this little pop-up menu with the double arrows, I can see all of the previous Find/Change routines that I've done. In this case the Dark chocolate and Milk chocolate, GREP that I was choosing. So I'll just load it back in there. Very, very easy to get that back into the Find/Change dialog box.

Just something to watch out for. Okay. Now it's time to do a little bit more complex GREP expression. I'm going to find all the words in my document that start with a letter c and end with e. So I'll type c in here and I'll type e here. But what's going to go in between the two? I'll click my cursor right between the c and the e. What's going to go in between there? Well, I need to type some codes that mean 'Find me some more characters.' I don't know what those codes are necessarily but the good news is that InDesign will type them for me.

I'll go over to this @ sign flyout menu and I'm going to choose a wild card or a meta character. The wild card that I'm going to choose is Any Letter. So I'll choose that and you can see that it types some codes for me. It did a square bracket, \l\u, and then closed square bracket. Well what does this mean? I'll tell you. It means a lowercase character or an uppercase character and because it's in square brackets it means one or the other of these. This is another way to do a this or that. In GREP there are multiple ways of doing the same thing.

But in this case it's only going to find three letter words that's start with c and end with e. We want it to be a four-letter or five-letter or eight-letter word or whatever. So we need to type one more code in here, a repeat code. So I'll go back to the flyout menu here and go to the Repeat submenu and I'm going to be going into much more detail about the Repeat submenu later on. But for right now I'm just going to tell you I'm going to choose One or More Times and that types in a little + code here. So now we have a code that says start with a c, then I want to have a string of one or more lower or upper case characters and then end with an e.

Now I'm going to tweak this code one more way. I want that to be lowercase or uppercase c. So I'll go ahead and type that square bracket, cC, closed square bracket, and again, this is just a different way of doing the same kind of this or that that we saw earlier. c or C followed by lower or uppercase characters, one or more of them and then ending with an e. All right let's try it out and see if it works. Find. There it goes. It found a word that starts with a c and ends with e. Find the next and this is great because it was also lowercase or uppercase. Remember? So it found that chocolate as well. Find Next, Find Next, Find Next. And I can just keep finding them until it finds this word, look at that. It even found coffee because coffee starts with c and ends with e.

Now there is one more thing I need to tell you about GREP codes and that is you are going to make mistakes. Everybody makes mistakes when doing GREP. I'm making mistakes while working on this title right now. In fact, if you're not seeing my mistakes, it's because the editors cut them out, but everyone makes mistakes, and that's okay. That's what undo is for. Just undo, Command+Z or Ctrl+Z on Windows and then look at your codes again carefully and then try it again.

There are currently no FAQs about InDesign: 10 Things to Know About GREP.






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed InDesign: 10 Things to Know About GREP.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.