Start learning with our library of video tutorials taught by experts. Get started

InDesign: 10 Things to Know About GREP
Illustration by John Hersey

8. Finding between


From:

InDesign: 10 Things to Know About GREP

with David Blatner

Video: 8. Finding between

I want to find all the ordinal numbers in my document like 3rd or 4th and apply superscript formatting to that rd or the th after the number. Of course, I don't want to apply superscript to all the rd's and th's throughout my document. That would be crazy. Just the ones that follow the numbers. Well, can we do that? Sure, not a problem at all if we are using GREP styles. So I'll open my Paragraph Styles panel and I'm going to right-click or Ctrl-click with a one-button mouse on Body and then Edit "Body". I'll jump over to GREP Style, add a new GREP style and I'm going to apply a new style and I'm going to call this my ordinal superscript style and I'll come over and say this is going to be a Superscript Style, OpenType superscript.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
InDesign: 10 Things to Know About GREP
1h 8m Intermediate Apr 30, 2009

Viewers: in countries Watching now:

With its ability to find and replace character patterns in documents, GREP helps designers and editors work quickly and efficiently. Over the course of InDesign: 10 Things to Know About GREP, David Blatner demonstrates how to use GREP codes to improve workflow. He teaches GREP search techniques using patterns of numbers or letters or strings of words. David even shows how to use text patterns within a document. Exercise files accompany the course.

Topics include:
  • Using pre-built find/change expressions
  • Reordering names in an exported list from a database
  • Working with GREP and fonts
  • Establishing character formats with GREP style
  • Using escape characters to customize code
  • Accessing the fly-out menus to specify search commands
  • Applying global conditions using GREP
Subject:
Design
Software:
InDesign
Author:
David Blatner

8. Finding between

I want to find all the ordinal numbers in my document like 3rd or 4th and apply superscript formatting to that rd or the th after the number. Of course, I don't want to apply superscript to all the rd's and th's throughout my document. That would be crazy. Just the ones that follow the numbers. Well, can we do that? Sure, not a problem at all if we are using GREP styles. So I'll open my Paragraph Styles panel and I'm going to right-click or Ctrl-click with a one-button mouse on Body and then Edit "Body". I'll jump over to GREP Style, add a new GREP style and I'm going to apply a new style and I'm going to call this my ordinal superscript style and I'll come over and say this is going to be a Superscript Style, OpenType superscript.

I'll click OK and now I need to define what's going to get that superscript applied to it. Right now it's every digit in the document. Of course that's not what I want. What I want is th's or rd's and I put that vertical bar between the two and I'm going to put those in parenthesis just to kind of hold those together as a unit. Now again I don't want any rd or any th. I only want ones that are after a number and I don't want it to apply to the number as well. For example if I put a digit here, any digit then ordinal superscript would also apply to the digit.

Well that doesn't work. So when I delete that and instead I need to say to InDesign, "look behind these letters" and in fact that's the name of the GREP code. It's called a Positive Lookbehind and I could find that in the Add pop-up menu here. Down in the Match sub-menu there is this thing called a Positive Lookbehind. That means if there is something behind this text then go ahead and apply the style and if it's not there, then don't apply the style. You'll notice that there is also a Negative Lookbehind and a Positive Lookahead and I'll be looking at this one in just a minute. But in this case I'm going to use a Positive Lookbehind.

Now it's a little frustrating because the code is entered but the cursor does not end up where it needs to be for me to type what I'm looking for. Instead I need the cursor just one character to the left, in between the equal and the parenthesis, and here is where I need to tell InDesign what I'm looking for, what's behind the th or rd. And that's going to be a digit just in number. I am looking for any digit followed by a th or rd and when it finds this, apply the superscript to it. Let's click off here and I'll move this out of the way and we'll be able to see a in little tiny letters here. There is a th after 18.

I'll click OK, zoom in here so we can see it a little bit better, here we go, 18th. Now I can find more of them by pressing Command+F or Ctrl+F and open the Find/Change dialog box and I'll just look for any digit followed by a th, say. Click Find, it finds that one, find it again. There we go June 5th. So it automatically is applying the correct style to the th or rd but only after a number. Here we go, there is an rd 23rd, so it applied it correctly. Now what if I wanted to apply formatting to anything inside parenthesis, not the parenthesis themselves but only stuff inside parenthesis. Well again we can do that with GREP styles.

I'll edit my Body style and I'm going to go to the GREP style and I'll create another GREP style in this case I'm going to apply a new style. I'll just leave it Character Style 1, it doesn't matter but this one's going to be Myriad Regular and let's go ahead and apply a color to it so we can see it a little better, maybe this burgundy color. Click OK and we don't want it applied to digits. I'm going to apply this to anything in between parenthesis. So I'm going to start with my open parenthesis character and I know I'm going to ending with a closed parenthesis character and in between those I'm going to be finding pretty much anything. Let's say a wildcard, let's say Any Character, and I don't know what's going to be in there and I'm going to Repeat it let's say One or More Time(Shortest Match ). So just the stuff that's in between parenthesis, but the problem here is it this code finds the text inside the parenthesis and includes the parenthesis.

That's not what I wanted, what I wanted was only the stuff in between the parenthesis. I can do that with a Positive Lookbehind and a Positive Lookahead. So instead I'm going to delete this parenthesis and I'm going to use my flyout menu here. Let me go grab my flyout menu. That will place my cursor just the right place, just before all of that and say Match Positive Lookbehind and between equal and the parenthesis I'm going to put a backslash parenthesis. Remember that escapes the parenthesis character. So it's going to be the opening parenthesis is behind the text I'm looking for and now I need one more of these Match Positive Lookahead and in between the equal and the parenthesis I need to have a escaped closed parenthesis character. So one more time this means any character.+?, it's going to be any character with a shortest match in which behind it is a open parenthesis and after it is a closed parenthesis. Click off of it, Preview is on, so we can see that it worked.

It only found the stuff that was inside parenthesis. Of course, this doesn't have to be parenthesis, we could remove this and put let's say quote marks in instead. I'll put a double quote there and I come over here and put a double quote here and now it's just going to find stuff that's inside quotes. I don't see anything right now but no problem. I'll just come up here, let's say quote here and quote here and suddenly anything that's in between those quotes gets that Character Style applied to it, and it's totally on the fly, totally automatic and totally great.

So as soon as I close that quote mark, it applies the character formatting automatically for me and that is great. It is so much more efficient than having to find these things manually.

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

 
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.

Upgrade to download 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.
Upgrade now


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 Upgrade now

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

Congratulations

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

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


OK
Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com 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.