Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Building with wild cards

From: Learning GREP with InDesign

Video: Building with wild cards

There are many different kinds of GREP metacharacters. Some describe specific characters while others indicate how often certain characters or portions of an expression repeat. Some describe locations and others apply conditions to searches. In InDesign, these different metacharacter types are grouped together logically in the Special Characters menu. In this movie, we're going to take a look at the first group of metacharacters called Wildcards. I'm zoomed in on the second page of this layout so that we can better see the text on the screen and my cursor is inside of this body copy text.

Building with wild cards

There are many different kinds of GREP metacharacters. Some describe specific characters while others indicate how often certain characters or portions of an expression repeat. Some describe locations and others apply conditions to searches. In InDesign, these different metacharacter types are grouped together logically in the Special Characters menu. In this movie, we're going to take a look at the first group of metacharacters called Wildcards. I'm zoomed in on the second page of this layout so that we can better see the text on the screen and my cursor is inside of this body copy text.

In the Paragraph Styles panel, you can see the Body Text, which is the style in use, is highlighted. I'm going to right-click on that style name or Ctrl+Click on the Mac and choose Edit "Body Text". This opens the Paragraph Style Options dialog and I'm going to go to the GREP style area. I'm using GREP styles to demonstrate these metacharacters because it's the only way in InDesign to actually preview the results of your GREP expressions as you build them. It's very helpful to do that as you're learning this. But in order to make that work, you need to make sure that the Preview checkbox at the bottom is actually checked on.

Now the GREP Style work area doesn't look like a whole lot, on first glance. It's just a big area with a new GREP Style button at the bottom. I'm going to click New GREP Style and my options here are to apply a style, which right now is set at None. If I click None, you'll see that it's actually a pull-down menu of all of the available character styles in this document. If I need to create a new character style, CS4 allows me to do that with this option at the bottom. In this instance, for this example, I'm going to use just this Yellow Highlight style that's already built into the document.

Below that is the To Text field. If I click on that, instantaneously, because Preview is checked, you'll see that this default expression, which is actually any digit one or more times, is automatically applied to the text on the page. You can see all of the numbers are highlighted with this Yellow Highlight character style, which basically just puts a thick underline below the text. Now, this default cannot be changed, unfortunately, so I need to clear it out each time I start a new GREP Style.

As soon as I click off in this gray area, that commits the change. So I can see the results on the page. I can still cancel. I don't have to save these changes to the style. Nothing is actually saved until I click OK. But by switching back and forth between the To Text field and clicking in this area, I can see what's going on, on the page, as I build my GREP expression. We're going to take a look at each of the Wildcard metacharacters in the Special Characters menu. At the end of the field, I'll click the Special Characters menu icon, and I'm going down to Wildcards.

Any digit we've already seen. It's \d, and if I click in the gray area you can see what we saw before, that those numbers are highlighted. I'll click back in the To Text field, clear that out by hitting Delete. I'm going to go back to the Special Characters menu at the end of the field, to the Wildcards submenu, and I'm going to skip Any Letter for now because it's a unique one that we're going to deal with at the end. I'm going to go to Any Character, which is the broadest of all the wildcard metacharacters.

It's the most far reaching. When I select that, I get a period, meaning any character. If I click off in the gray area to preview the results, you can see it matches exactly that, any character, punctuation, uppercase and lowercase letters, digits, spaces, everything except a hard return. That's the only thing outside of the scope of the Any Character metacharacter. I'm just going to clear that metacharacter out of the To Text field, and let's take a look at the next wildcard in the list.

Under the Wildcards submenu, I'm going to choose Any White Space. Fortunately, because I'm using a character style that actually highlights the space occupied by the character with a yellow underline, this will actually show up. If I choose Any White Space, I get the \s metacharacter. I'll click in the gray area and you can see it matches Any White Space. If I zoom in here, you can see that around this em dash, I'm using two InDesign custom white spaces.

They're little bit thinner than the standard Spacebar white space. These are thin spaces, and they also match, because Any White Space is matched. In fact, I'm going to click OK while this is still part of the style. I'm going to go on to the page and come over to the beginning of one of these paragraphs and I'm just going to type in a Tab. A Tab also qualifies as a white space. You'll notice that as soon as I typed it, the character style was automatically applied. This is what GREP styles do. As I add more spaces, since Any White Space is what's being styled, every white space that I add is automatically and dynamically styled with that character style.

I don't actually need these, undo that change altogether and go back to the Body Text style in the Paragraph Styles panel, right-click on it, choose Edit "Body Text" and let's take a look at the next wildcard. Once again, I'll create a new GREP style, since I undid the last one. I'm going to choose Yellow Highlight again. This is the default, unfortunately, that we're going to encounter every time we start one of these. I'll clear that out, and I'm going to choose the next wildcard in the list, which is Any Word Character.

Any Word Character applies the style that you choose to Any Uppercase Letter, Any Lowercase Letter, Any Digit, and the underscore character. So let's see what we get when we chose that. \w is the metacharacter itself. If I click off in the gray area, let's zoom out a little bit, so you can see some more here. You can see that it matches exactly that. Any Word Character, uppercase or lowercase letter, number or underscore, but it doesn't match white spaces, or punctuation, and none of those are highlighted here.

I'll clear out that Any Word Character wildcard and we'll take a look at the next wildcard in the list. That is Any Uppercase Letter, which is pretty straightforward. It's \u. When I click off the gray area, you can see that it matches every uppercase letter, all of the ones at the beginning of sentences, the complete uppercase sentence. There's one little thing that you do need to be aware of when you choose this. I'm going to zoom in down here where this ligature is and you'll notice that InDesign is considering the whole ligature, both letters, as a single uppercase character even though part of it is actually a lowercase character.

InDesign has ligatures turned on, by default, and this is how GREP treats ligatures when it encounters them. Even though you can still select them as separate characters, they're considered by GREP to be one character. So this is just something that you need to be aware of. I'm going to go back here and I'm going to choose the next wildcard from the list. I'll clear that one out. From the Wildcards menu, I'll choose Any Lowercase Character. Again, fairly self-explanatory, the metacharacter is \l. If I click in the gray area, you can see that that's what it matches.

Let me zoom out here and I've matched all of my lowercase characters. You'll also notice that that ligature is not selected at all, even the h portion of it. So this treatment of ligatures by Any Uppercase Letter and Any Lowercase Letter metacharacters works both ways. I'm going to clear that out and click off here so that all of that formatting is removed. We're going to go back to the one item in that wildcard list that I skipped, and that is the Any Letter metacharacter.

If I select that, you'll notice that the syntax here is quite different. It's actually the Any Lowercase and Any Uppercase Letter metacharacters enclosed in square brackets. Anything enclosed in square brackets is what's called a character set. So this is technically not a wildcard by itself. It's two wildcards combined together in a character set, which we'll discuss in the later movie. That's been included here in InDesign, because it's a very convenient choice.

It's useful to have, but it's actually not a true and unique wildcard. So wildcards stand in for particular types of characters from something as broad as Any Character to more specific like Any Digit or Any Lowercase Character. Except for that Any Letter option, those are all of the documented InDesign wildcards you'll see available in this list. However, there are few wildcards that are not in the Special Characters menu, nor are they listed in the Help files.

We'll take a look at some of those hidden gems, in the next movie.

Show transcript

This video is part of

Image for Learning GREP with InDesign
Learning GREP with InDesign

42 video lessons · 12984 viewers

Michael Murphy
Author

 
Expand all | Collapse all
  1. 1m 33s
    1. Welcome
      1m 4s
    2. Using the exercise files
      29s
  2. 7m 56s
    1. What is GREP?
      1m 53s
    2. Text searching vs. GREP searching
      2m 35s
    3. Working with GREP and InDesign
      3m 28s
  3. 46m 4s
    1. Using metacharacters, the building blocks of GREP
      6m 37s
    2. Escaping out metacharacters
      2m 49s
    3. Building with wild cards
      9m 9s
    4. Understanding undocumented wild card "opposites"
      3m 11s
    5. Specifying locations
      7m 4s
    6. Learning the undocumented location metacharacters
      4m 45s
    7. Using repeat metacharacters and defining the shortest match
      5m 45s
    8. Specifying exact matches and ranges
      2m 52s
    9. Finding content that doesn't exist with zero functions
      3m 52s
  4. 43m 26s
    1. Creating "or" conditions
      5m 24s
    2. Building subexpressions
      5m 52s
    3. Using character sets to create custom wild cards
      7m 3s
    4. Using negative character sets
      3m 2s
    5. Finding around text with lookbehind and lookahead
      8m 1s
    6. Building with modifiers: Case sensitivity
      4m 0s
    7. Building with modifiers: Single-line and multi-line
      3m 10s
    8. Using InDesign-compatible Posix expressions
      6m 54s
  5. 49m 18s
    1. GREP styles vs. nested styles
      6m 10s
    2. Styling specific words or phrases
      3m 18s
    3. Describing inconsistent text
      6m 59s
    4. Describing and styling prices
      6m 55s
    5. Applying multiple character styles to the same text
      6m 8s
    6. Describing and styling email addresses
      10m 48s
    7. Dynamically fixing orphaned words with GREP
      9m 0s
  6. 33m 30s
    1. Adding more to the mix: GREP Find/Change
      1m 41s
    2. Understanding queries
      8m 20s
    3. Using formatting and styles as Find/Change criteria
      5m 20s
    4. Preserving and recalling using subexpressions
      7m 49s
    5. Backreferences in search queries
      3m 8s
    6. Cleaning up text with GREP
      2m 45s
    7. Creating a GREP-based text cleanup script
      4m 27s
  7. 43m 45s
    1. Describing imported spreadsheet data
      6m 56s
    2. Rearranging imported spreadsheet data
      7m 17s
    3. Applying styles and formatting with GREP
      11m 14s
    4. Describing and standardizing phone numbers
      9m 20s
    5. Inserting anchored objects with GREP
      8m 58s
  8. 27s
    1. Goodbye
      27s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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

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 Learning GREP with InDesign.

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 preferences from 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.

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 lynda.com 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 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.