Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The Wildcard Metacharacters we saw in a previous movie, like any digit, any character, and so on, provide a quick convenient way to describe common character types. But you may find yourself wanting to define your own custom wildcards of specific characters to be matched. That's what the next option under the Match sub-menu, Character Sets, allows you to do. I'm zoomed in on the top part of Page 3 in this document, and my cursor is inside of the body text, which is why you see it highlighted here in the Paragraph Styles panel, where I'll right-click it, choose Edit Body Text and go to the GREP Style area.
I am going to create a New GREP Style to demonstrate how character sets work. From the Apply Style menu, I am going to choose the existing Red character style. That will just color the text red on the page and the default of any digit one or more times is in here. Again, if I just click in there, you'll see that it highlights any digit on the page. That's actually a useful starting off point because any digit means any digit, 0 through 9. But what if you wanted to define only a handful of digits? Let's just say 1 through 5.
One way to do that would be to type 1, the Or metacharacter, 2, another or metacharacter, 3 or 4 or 5 and when you click off, that's what you will match, any of those digits, one or the other. The problem is the Or Metacharacter is neither the best nor the most efficient way to do this. When you use a character set, I'll clear this out here, click off and then go to the Special Characters menu at the end of the field, go down to the Match sub-menu and choose Character Set.
That inserts an opening left square bracket and a closing right square bracket. Anything that exists inside those brackets is part of your character set, so whatever you put in there is designated to be a valid matching character for whatever you're looking for. So within here, I could just type 12345 without an Or metacharacter because within a character set or is implied. Anything in there is a match so 1 or 2 or 3 or 4 or 5. So I'll click off here and you can see that the result is the same as we saw before, without needing the Or metacharacter and just typing in the numbers in succession.
They don't even have to be in that specific order. It could be any random order of those digits. This is still yet not the most efficient way of doing this. Within a character set, there is a way to streamline this even further. I am going to click in here and I am going to select 2, 3, and 4, delete them and replace them with a dash. I'll click off here and you can see that nothing has changed on the page. I'm still only matching numbers between one and five and nothing above that, but I'm doing it by describing it as a range of digits from 1 through 5.
And I can do that from 2 through 7 and click off, and you can see what changes on the page" 2s, 5s, 7s but no 1s, no 8s, no 9s, that sort of thing. So you can describe a very specific range to suit your needs using this and it also works on alphabetical characters as well. So if I typed 'a-z' and clicked off, you'd see I've matched every lowercase letter from a to z. If I only wanted to match a through k, I could just replace that z with a k and I only get letters a through k in lowercase.
If I wanted to match a through k in both upper and lowercase, I would just append A-K after that, within the character set, and I click off and you'll see those matches here. C is colored red, A is colored red, O is not and so on. So this is good for creating a very finite and specific set of characters that you need to match. Suppose, however, you needed to describe an actual dash as part of your character set. That's one of the characters you want to match.
The safest thing to do when you're doing that is to put the dash at the beginning of the character set. For example, if I type 1 through 5 or 1-5 rather, click off. I'll get a range of digits from 1 through 5. But if I want to find a dash, a 1 or 5, I'll cut that dash out of there and paste it at the beginning of the character set. When I click off, you can see what I match. I matched 1. I matched a 5 and then down here, in the word 'forty-eight', I matched a dash.
So, whenever you need to include a dash in a character set, the safest bet is to put it at the beginning of the character set so it doesn't get confused as a range-definer for any alphanumeric characters that might be around it. Another thing to be aware of when working with character sets is that certain metacharacters, specifically the single character metacharacters, like a period for any character, and a question mark for 0 or 1 times, those characters do not retain their meaning when they exist inside of a character set. For example, I'll delete what's in here and click off, and then within this character set, I am just going to type a period, which normally means any character.
But when I click off, you'll see that it's actually only colored periods on the page, in red. It no longer means any character. The same applies for question marks and asterisks and the Plus sign. Any of those single character metacharacters no longer retain their special meaning. I always think of it as a character set is like kryptonite on single character metacharacters. It just strips them off their special powers and they become the normal mild-mannered punctuation marks that they normally are.
Other metacharacters, however, act just like you'd expect them to. If I delete all this out of here and I put in \d for any digit, \u for any uppercase letter, and click off, I match exactly that. They're still metacharacters within there. So if a metacharacter uses the backslash or tilde syntax, and is composed of one or more characters to define a specific character type, that will still work inside of a character set. It's only the single character metacharacters that don't. In fact, there is a character set built into the Wildcards in InDesign's Special Characters menu.
If I delete this, go to the Special Characters menu and go to Wildcards and choose Any Letter, you can see that that's actually a character set. It's the any lowercase letter and any uppercase letter metacharacters enclosed within a character set. It's placed in there as a convenience. It's not an individual wildcard. It's two wildcards built into a character set. So when you need to define several characters as an acceptable match, a character set is the way to do it. Remember though, that dashes can define a range of alphanumeric characters and single character metacharacters lose their meaning inside of a character set and revert to standard characters.
Get unlimited access to all courses for just $25/month.Become a member
120 Video lessons · 58344 Viewers
119 Video lessons · 67607 Viewers
84 Video lessons · 16884 Viewers
125 Video lessons · 29783 Viewers
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.