1. Ten Things to Know About GREP1. GREP basics: Using codes to find text| 00:05 | So GREP is all about finding patterns
of text and you're already familiar with
| | 00:09 | patterns of text. Like what's a bunch
of letters all grouped together?
| | 00:12 | Well, that's a word, right? Or what's a
bunch of words all grouped together. Well,
| | 00:16 | that's a sentence or maybe a paragraph.
| | 00:19 | But you can't say to InDesign, find me
a bunch of words all grouped together.
| | 00:23 | Now you need to type in codes, GREP
codes. That's what InDesign is expecting.
| | 00:27 | So the good news is that those codes
are either really simple or InDesign will
| | 00:32 | actually type them for you.
| | 00:34 | Now because we're searching for text
the best place to go and do that is the
| | 00:39 | Find/Change dialog box. I'll open
the Find/Change dialog box by pressing
| | 00:43 | Command+F or Ctrl+F on Windows and
we'll see that there are actually four
| | 00:47 | different dialog boxes in one here:
Text, GREP, Glyph and Object. We're going
| | 00:52 | to be focusing not on text, which is
where most people do their work but
| | 00:55 | instead on GREP.
| | 00:57 | So I'll click on GREP or you can press
Command+2 or Ctrl+2 on Windows to jump
| | 01:01 | to that second tab and I'm going to
type my code into the Find What field.
| | 01:06 | So I'm going to search for some kinds of
chocolate. Let's say I'll search for a
| | 01:10 | Milk chocolate and I'll click Find and
it will jump right to the first instance
| | 01:16 | of Milk chocolate. Let's see where is
that, there it is, right in the text here.
| | 01:19 | And I zoom in to 200% here. I'll
click on the document and then go into
| | 01:24 | 200% with a Command+2 or Ctrl+2 on
Windows, and there is the text that I found
| | 01:29 | Milk chocolate.
| | 01:30 | But in this case I want to find Milk
chocolate or maybe Dark chocolate, one or
| | 01:36 | the other. So let's go ahead and type
in some codes for that. I'm going to type
| | 01:41 | Dark here at the beginning and I want
to tell InDesign to search for either
| | 01:45 | Dark or Milk chocolate. So I'm going
to add a vertical bar. On the US keyboard
| | 01:50 | that's Shift+\, gets that vertical bar
in between them. And I also need to put
| | 01:55 | some parenthesis around this. So
it's going to be Dark or Milk chocolate.
| | 02:00 | That's our first code. Let's go and
try it out. Find that and it finds Milk
| | 02:05 | chocolate, Find again
and it says it's completed.
| | 02:08 | Well I know there are some other
instances of Dark chocolate and Milk chocolate
| | 02:11 | in this document; it's a whole magazine
about chocolate after all. So I need to
| | 02:15 | find out why it's not working. So here
is the key. GREP is case-sensitive.
| | 02:20 | You always have to pay attention to the
case of every character. So in this case
| | 02:24 | it's looking for D, M and c, but if
change that to a C and hit Find,
| | 02:32 | now it will find it. It will find Milk
Chocolate, click Find again, there is Milk
| | 02:36 | Chocolate and there is Dark Chocolate.
So it will find either Dark or Milk Chocolate.
| | 02:40 | Now if I want to tell that GREP code
to search for lowercase or uppercase,
| | 02:45 | I need to add a few more codes in here.
So I'm going to put in some more
| | 02:49 | characters. This is going to be either
lowercase or uppercase d. Did you see that?
| | 02:54 | I put in an open parenthesis
and then a lowercase and then a vertical
| | 02:58 | pipe and an uppercase d and then closed
parenthesis, and I'll do the same thing
| | 03:02 | here for the m, lowercase or uppercase m.
And I'll do the same thing for the c.
| | 03:07 | This is little bit more verbose than
you need to be. There is more codes in
| | 03:11 | here than you actually need, but it's
a very easy way to see what's going on.
| | 03:15 | Dark chocolate, lowercase or uppercase,
lowercase m or uppercase and lowercase
| | 03:20 | or uppercase c.
| | 03:21 | So now we have a lot of flexibility in
here. It's going to be looking for Dark
| | 03:24 | or Milk chocolate in uppercase or
lowercase characters. Let's try it out.
| | 03:29 | Find it, find it, find it. There we go. It's
going to keep looking around and there we go.
| | 03:33 | There is the Dark chocolate in lowercase.
Both d and c are in lowercase here as well.
| | 03:39 | I want to point out one little trick
here that I need to warn you about.
| | 03:42 | If I use the Option+Spacebar or Alt+Spacebar
trick to use my grabber hand to try and
| | 03:48 | scroll this over, I'm going to have a
problem and that problem is that my GREP
| | 03:53 | code will disappear. This always
catches me. It's very, very frustrating.
| | 03:57 | For example I'll do Option+Spacebar and
I'll start to be able to scroll around,
| | 04:01 | but look what happened to my GREP code.
It completely disappeared. That is very
| | 04:05 | frustrating. Maybe it's a bug in
InDesign, I don't know. But it actually typed
| | 04:09 | a bunch of spaces here because the GREP
code was selected. Fortunately there is
| | 04:14 | a way to get those codes back.
| | 04:15 | So if I click on this little pop-up
menu with the double arrows, I can see all
| | 04:19 | of the previous Find/Change routines
that I've done. In this case the Dark
| | 04:23 | chocolate and Milk chocolate, GREP
that I was choosing. So I'll just load it
| | 04:27 | back in there. Very, very easy to get
that back into the Find/Change dialog box.
| | 04:31 | Just something to watch out for.
| | 04:33 | Okay. Now it's time to do a little bit
more complex GREP expression. I'm going
| | 04:37 | to find all the words in my document
that start with a letter c and end with e.
| | 04:42 | So I'll type c in here and I'll type e here.
But what's going to go in between the two?
| | 04:47 | I'll click my cursor right between
the c and the e. What's going to go
| | 04:51 | in between there? Well, I need to type
some codes that mean 'Find me some more
| | 04:55 | characters.' I don't know what those
codes are necessarily but the good news is
| | 05:00 | that InDesign will type them for me.
| | 05:02 | I'll go over to this @ sign flyout menu
and I'm going to choose a wild card or
| | 05:06 | a meta character. The wild card that
I'm going to choose is Any Letter.
| | 05:11 | So I'll choose that and you can see
that it types some codes for me.
| | 05:14 | It did a square bracket, \l\u,
and then closed square bracket.
| | 05:20 | Well what does this mean? I'll tell you.
It means a lowercase character or an
| | 05:24 | uppercase character and because it's
in square brackets it means one or the
| | 05:28 | other of these. This is another way
to do a this or that. In GREP there are
| | 05:33 | multiple ways of doing the same thing.
| | 05:34 | But in this case it's only going to
find three letter words that's start with c
| | 05:37 | and end with e. We want it to be a
four-letter or five-letter or eight-letter word
| | 05:41 | or whatever. So we need to type
one more code in here, a repeat code.
| | 05:46 | So I'll go back to the flyout menu
here and go to the Repeat submenu and
| | 05:51 | I'm going to be going into much more
detail about the Repeat submenu later on.
| | 05:55 | But for right now I'm just going to
tell you I'm going to choose One or More
| | 05:58 | Times and that types in a little +
code here. So now we have a code that says
| | 06:03 | start with a c, then I want to have a
string of one or more lower or upper case
| | 06:08 | characters and then end with an e.
| | 06:10 | Now I'm going to tweak this code one more way.
I want that to be lowercase or uppercase c.
| | 06:16 | So I'll go ahead and type that square bracket,
cC, closed square bracket, and again, this is just
| | 06:24 | a different way of doing the same kind of
this or that that we saw earlier. c or
| | 06:29 | C followed by lower or uppercase characters,
one or more of them and then ending with an e.
| | 06:34 | All right let's try it out and see if
it works. Find. There it goes. It found a
| | 06:39 | word that starts with a c and ends
with e. Find the next and this is great
| | 06:43 | because it was also lowercase or
uppercase. Remember? So it found that
| | 06:47 | chocolate as well. Find Next, Find Next,
Find Next. And I can just keep finding
| | 06:51 | them until it finds this word, look
at that. It even found coffee because
| | 06:56 | coffee starts with c and ends with e.
| | 06:58 | Now there is one more thing I need to
tell you about GREP codes and that is
| | 07:02 | you are going to make mistakes.
Everybody makes mistakes when doing GREP.
| | 07:06 | I'm making mistakes while working on this
title right now. In fact, if you're not
| | 07:09 | seeing my mistakes, it's because the
editors cut them out, but everyone makes mistakes,
| | 07:14 | and that's okay. That's what undo
is for. Just undo, Command+Z or
| | 07:18 | Ctrl+Z on Windows and then look at
your codes again carefully and then try it again.
| | Collapse this transcript |
| 2. Using GREP in the Find/Change dialog box| 00:02 | Now let's go a little bit deeper
into GREP, creating a more complicated
| | 00:05 | expression. I'll open up the Find/
Change dialog box by pressing Command+F or
| | 00:09 | Ctrl+F on Windows and I'm going to
jump over to the GREP tab by pressing
| | 00:14 | Command+2 or Ctrl+2 on Windows.
Always make sure you're in the GREP tab if
| | 00:18 | you're going to be typing GREP character codes.
| | 00:20 | I am going to be filling in both the
Find What and the Change To fields.
| | 00:25 | But before I do that, I want to take a
look at the Query pop-up menu and this is
| | 00:29 | whole bunch of preset Find/Change
queries that Adobe has given us. The ones
| | 00:34 | at the top are regular text Find/
Change queries, the ones at the bottom are
| | 00:37 | object queries and the ones in the
middle are GREP Find/Change expressions.
| | 00:42 | For example if I choose this Dash to
En-dash, I can see a really long set of
| | 00:46 | codes in here. In fact it's long
I can't even see all of the codes.
| | 00:50 | So I'll show you little trick. I'll hover my
cursor over the field and it shows me the
| | 00:55 | entire expression. Well, what is going
on there? I don't need to get into all
| | 00:59 | the details here. But what this means
is find a space character. It could be
| | 01:03 | any kind of space character. A regular
space or an Em space or a hair space.
| | 01:08 | That's what all these codes are.
| | 01:10 | All the different kinds of spaces
that InDesign knows about, followed by a
| | 01:13 | hyphen, a dash, followed by another
one of those spaces. That's what's really
| | 01:17 | going on there. And it's finding all
of those things and it's changing it to
| | 01:21 | this little code here, which means
space followed by a regular en-dash followed
| | 01:26 | by a space. That's all that means. It
normalizes all of those different space
| | 01:31 | dash spaces into just the space en-dash space.
| | 01:35 | All right. So that's one of the ones
that Adobe gave us. Let's look at another
| | 01:38 | one then here. How about Remove
Trailing Whitespace? This is a little simpler,
| | 01:43 | \s means any whitespace. So that could
be a space character or a tab character
| | 01:49 | or a return, anything that's just
whitespace and then one or more of them. That
| | 01:53 | little plus there means one or more of
the previous character. So one or more
| | 01:58 | whitespace characters and
then what's this dollar sign?
| | 02:01 | Well I'm going to be talking about
location codes a little bit later on in
| | 02:04 | quite some depth, but I'll just tell
you know, I'll give you a little hint.
| | 02:08 | That means at the end of a paragraph.
So this is one or more white spaces at
| | 02:13 | the end of a paragraph. And because
Find What is filled in and Change To is
| | 02:17 | empty and the Find Format and Change
Format fields are empty as well, that
| | 02:22 | means it's going to search for all of
these white spaces and if I hit Change
| | 02:26 | All, it's going to delete them all. So
it deletes all of the whitespaces at the
| | 02:30 | end of a paragraph. Let's try it out.
| | 02:32 | I'll click Find and it jumps right
over to this one. There is a whitespace
| | 02:36 | there, I better say Change/Find and
Change/Find. And you could see it's just
| | 02:40 | removing all of these things. I can't
even see all of these. Let's zoom in here
| | 02:44 | to 200% and I'll turn on Type > Show
Hidden Characters, there we go. I can
| | 02:49 | actually see the little dot there,
the green dot means that it's a regular
| | 02:52 | space there at the end of the paragraph.
| | 02:54 | So I'll say Find it. Yep, there it is.
Change then find, change then find. It's
| | 03:00 | finding all of those whitespaces and
removing them. It could be 1 or 15 or 100
| | 03:05 | spaces in a row. It doesn't
matter. It will find all of them.
| | 03:07 | In fact this code will even find
multiple returns. I just place the cursor at
| | 03:12 | the end of that paragraph and hit
Return or Enter a couple of times to move
| | 03:16 | down. So I have these blank paragraphs
down here and this code will find that
| | 03:21 | as well. Let's try it out. I'll place
my cursor above the text, click Find.
| | 03:25 | There it goes. It found it. I can't see
everything on my screen here but it did
| | 03:29 | find it. It found all of those.
| | 03:31 | In fact if I click Change All, it
will go through my entire document and it
| | 03:35 | will delete all of them including those
blank lines. Well that may be what you
| | 03:39 | want. Maybe that's exactly what you
want and that's great or maybe it's not
| | 03:43 | what you want. You wanted it remove the
spaces and tabs at the end but you did
| | 03:47 | not want it to remove the blank
returns. If that's the case, well we better
| | 03:52 | massage our code a little bit.
| | 03:54 | So I'm going to undo that with a Command
+Z or a Ctrl+Z on Windows and I'll come
| | 03:58 | in here and change the code. I'll
delete the Any Space character, this wild
| | 04:02 | card, and I'm going to instead tell it
exactly which kind of spaces I want it
| | 04:06 | to look for. So I'm going to put it
inside of a square bracket. So I have an
| | 04:11 | open square bracket and I'm going to
say find me any, let's say tab.
| | 04:16 | How do I type the tab code? I don't know.
But it's easy to pull it out of that little
| | 04:20 | @ sign flyout menu here. Tab, oh, there
it is. It's \t. So it typed it for me.
| | 04:26 | Then maybe I want just any regular
space. So I'll just type the space on the
| | 04:30 | spacebar on the keyboard and that
typed that kind of space and then maybe we
| | 04:34 | want some other kind of spaces as well.
I'll come out here to the White Space
| | 04:38 | pop-up men in the @ sign flyout menu
here and I'll say let's find any em-space
| | 04:43 | as well. Then I'm going to close that
expression with a close square bracket.
| | 04:49 | So it's tab or a regular space or an em-
space, and I want one or more of them,
| | 04:54 | so my plus sign is there, and I only
want it at the end of the paragraph and
| | 04:58 | that's why that dollar sign is. Now
when I say Change All, it will go to the
| | 05:02 | entire document, 21 replacements made,
click OK and it removed all of them but
| | 05:08 | it did not find or replace my blank returns.
| | 05:11 | Okay one last thing that we're going
to search for here, let me pan down to
| | 05:16 | this e-mail address. I want to find e-
mail addresses in my document. So how am
| | 05:21 | I going to do that? Well I need a new
code. So I'll go ahead and delete that
| | 05:24 | one and I'm going to start building
my code for e-mail addresses. This is
| | 05:29 | really exactly how I build these codes.
I don't memorize the whole thing;
| | 05:32 | I build it piece by piece.
| | 05:34 | So I'm going to start with an @ sign
because I know all my addresses have an @
| | 05:37 | sign in them. Now on the right side of
my @ sign I know that I want characters
| | 05:43 | because I know it's going to be
lowercase or uppercase characters. So I'll find
| | 05:47 | my wild card that is Any Letter.
There we go. Any lowercase or uppercase
| | 05:52 | character and I know that I want one
or more of them. Not just one character
| | 05:57 | but I want it to repeat it one or more times.
| | 06:00 | I also happen to know that there's a
5 in here. So I need a digit as well.
| | 06:04 | Lowercase character, uppercase character,
or I'll click just after the u there.
| | 06:09 | I need a wild card for any digit. That's a \d.
| | 06:13 | So now I found any lowercase uppercase
or digit, one or more of them after the
| | 06:18 | @ sign, and what about before the @ sign?
Well that's easy. I can select all of
| | 06:22 | that, copy it with Command+C or Ctrl+C
on Windows, click before the @ sign and
| | 06:28 | Command or Ctrl+V to paste it in here.
So now I'm searching for some text, some
| | 06:33 | words, @ sign and then another
text or word. Let's try it out.
| | 06:37 | I'll place my cursor up here, click Find.
Uh-oh! It didn't get the whole e-mail
| | 06:41 | address. It got the text before it and
the @ sign and this but it didn't get
| | 06:45 | the .com. Why? Well you see always
making mistakes. You always have to look at
| | 06:50 | it and troubleshoot the GREP code. I
can see that - Oh! You know what? It's
| | 06:54 | searching lowercase, uppercase or
digits but it's not finding this little dot,
| | 06:59 | the period there. So I better type the
period. Because it's inside the square
| | 07:03 | brackets I can just type the period on
my keyboard before and after it because
| | 07:08 | there might be a period before it as well.
| | 07:10 | That is going to be a pretty robust
GREP code for finding my e-mail addresses.
| | 07:15 | Maybe there would be hyphen, I don't
know, maybe there is underscores. I could
| | 07:18 | add those to my expression as well.
But for right now in this document
| | 07:22 | I'll keep that relatively simple here and
see if this works. Let's say Find it. Yep,
| | 07:26 | there we go, it found the entire e-mail address.
| | 07:28 | Well now once I've found it, what am I
going to do with it? Well I would like
| | 07:32 | to apply formatting to it. I'm not
going to change the e-mail address, I'm just
| | 07:35 | going to apply formatting to it. So I'm
going to do that by clicking down here
| | 07:39 | in the Change Format field, and when
we're inside this field, we'll open the
| | 07:43 | Change Format settings dialog box and
I'm going to apply a character style to it.
| | 07:48 | So my character style is going to
be my e-mail style. I don't see one here.
| | 07:53 | So I'll go ahead and make a new one.
| | 07:55 | This is one of my favorite new features
in InDesign CS4, the ability to create
| | 07:58 | a new character style without having to
close the dialog box then come back to
| | 08:03 | it later. Just pull it right out of
that pop-up menu and this is going to be my
| | 08:07 | e-mail style and I'm going to change
the font let's say I'll make it Myriad and
| | 08:12 | I'll change the color so it'll be
more obvious on screen here. Why don't we
| | 08:16 | make it this kind of burgundy color?
So it will fill with a burgundy color.
| | 08:19 | Click OK, click OK.
| | 08:22 | So now I can see that I have a code in
the Find What field but nothing in the
| | 08:26 | Change To field. Does that mean it's
going to delete the e-mail address? No.
| | 08:30 | Because I have chosen something in
the Change Format field. So when I have
| | 08:34 | something in Find What and something
in Change Format, but nothing in Change
| | 08:38 | To, it means don't change it, ignore it.
Don't change the words at all, just
| | 08:43 | apply formatting to it. Let's try it out.
I'm going to click Change All and it
| | 08:48 | went through my whole document, it
made the re-replacements and you can see
| | 08:51 | that it changed all my e-mail
addresses into this character style.
| | 08:56 | Okay the last thing I'm going to do
here is save my Find/Change query. Because
| | 09:00 | if you've spent more than 30 seconds
on one of these GREP codes, you should
| | 09:03 | save it. I mean you're probably going
to want to use it again later.
| | 09:05 | So to save this, just go ahead and click
this little disc icon and it saves it to disc.
| | 09:10 | I'll call this my format e-mail
addresses. Click OK and now that shows up
| | 09:18 | in my Query pop-up menu as well.
| | Collapse this transcript |
| 3. Using GREP for styles| 00:05 | I'm going to zoom into the lower
left corner of this page and I can see that
| | 00:08 | inside these paragraphs, I have numbers
and I want to apply special formatting
| | 00:12 | to just the numbers.
| | 00:14 | Now, I know that I could use the Find/
Change dialog box to type in special GREP
| | 00:18 | codes and apply formatting using those
codes, but the problem is what happens
| | 00:22 | if my text gets changed? If I add a
number somewhere? Well, that's a big problem
| | 00:27 | because I would have to run the Find/
Change query over again. Kind of annoying.
| | 00:31 | So wouldn't it be cool if there were
some way to apply formatting using GREP
| | 00:35 | codes that would happen automatically
in the background? Just add a number and
| | 00:40 | boom, it would change. Well there is
and it's called GREP Styles. And it's one
| | 00:44 | of my favorite features in InDesign
CS4. Let me show you how it works.
| | 00:48 | You can apply GREP Style to a
single paragraph if you want to, just by
| | 00:51 | selecting that paragraph or any part
of that paragraph, coming up to the
| | 00:55 | control panel fly-out menu
and choosing GREP Styles.
| | 00:58 | The problem with doing it this way is
that it affects just that one paragraph.
| | 01:02 | That's kind of annoying because I
wanted to change my entire document not one
| | 01:05 | paragraph. So I never use this I just
wanted to show you that it is possible,
| | 01:09 | you can change a single paragraph.
I'll cancel out of that and instead
| | 01:13 | I'm going to go to the Paragraph Styles
panel. This makes a lot more sense.
| | 01:17 | Edit the Paragraph Style that is
applied to all of these paragraphs.
| | 01:21 | In this case it's Body, so I'm going
to right-click on Body choose Edit and
| | 01:25 | then move over here to the GREP Style pane
of the Paragraph Style Options dialog box.
| | 01:31 | Now this user interface is a little
bit clunky, it's not very intuitive in my
| | 01:34 | opinion, but once you see how to do it
once it's totally obvious. You will get
| | 01:38 | it right away. Let me show you. First
click New GREP Style then type the GREP
| | 01:44 | code that you want to search for inside
that your text field. Well, this is a problem.
| | 01:49 | It doesn't look like there is
any kind of editable field here, right?
| | 01:52 | Well, there is. How do you get it
editable? You just click on it,
| | 01:55 | just click once and boom.
| | 01:56 | Now it's editable and we can see that
this GREP code is backslash d (\d), which
| | 02:01 | is the code for a digit, and then the
plus symbol, which means one or more.
| | 02:05 | So this is the code for one or more
numbers, which is in fact exactly what I was
| | 02:10 | aiming for. So I don't even need to
edit this default GREP code at all.
| | 02:13 | Now I need to choose a character style from
the Apply Style pop-up menu here and once
| | 02:18 | again it doesn't look like there is a
pop-up menu, until you click on it, then
| | 02:22 | it activates it. So I'll go down here
and I'll see that I don't have one that
| | 02:26 | I want to apply yet so I'll choose New
Character Style. And I'm going to say this
| | 02:30 | is my number style and why don't I go
ahead and change the color to something else?
| | 02:35 | Maybe magenta and maybe I'll change it
somehow like make a Proportional Oldstyle.
| | 02:41 | So it's going to be a different color
and it's going to be Oldstyle.
| | 02:44 | Because I have the Preview checkbox turned on here,
I'll move the dialog box over a little bit,
| | 02:49 | you can see that all the
numbers in all of these paragraphs get
| | 02:52 | changed to magenta and the Oldstyle
numerals, pretty cool. I'm going to click
| | 02:57 | OK here and I'm going to scroll over,
pan over here to this paragraph up at the
| | 03:02 | upper right corner and I can see
that there are fractions in here. That's interesting.
| | 03:07 | Fractions are going to be different.
Fractions can be a real pain in
| | 03:11 | InDesign, but there is the open type
fraction formatting that you can apply but
| | 03:15 | it's just really annoying because you
can't apply the fraction formatting to
| | 03:18 | the entire paragraph because all of
your punctuation will go berserk. So,
| | 03:22 | instead you only want to apply it to
things that look like a fraction. Well
| | 03:25 | I said looks like a fraction, right
that sounds like I'm defining a pattern,
| | 03:29 | things that look like a fraction.
Let's go ahead and see how it's done.
| | 03:33 | I will double-click on Body because
that's actually what's still selected here
| | 03:36 | and I'm going to go the GREP Style pane
here and click New GREP Style and
| | 03:40 | this time I'm going to apply a fraction
style to anything that looks like a fraction.
| | 03:46 | \d, plus because I want it to be
one or more numbers, followed by a
| | 03:50 | slash, just a regular slash on the
keyboard followed by \d+. There we go.
| | 03:55 | That's what a fraction looks like.
| | 03:57 | One or more numbers followed by slash,
followed by one or more numbers and
| | 04:01 | I'm going to apply a special character
style to it, New Character Style. I don't
| | 04:06 | know why the document reflowed in the
background there that's kind of weird
| | 04:09 | probably a little redraw glitch there,
sometimes InDesign does that. That's okay.
| | 04:12 | I'm going to come to the OpenType
Features and I'm going to turn on
| | 04:15 | Fractions. And in fact, I'll call this
my fraction style and I might as well
| | 04:21 | also change the color because I wanted
that magenta colored numbers I'll make
| | 04:25 | this magenta as well. Click OK, click
OK and then zoom back up here and we can see,
| | 04:32 | there we go.
| | 04:33 | Now I automatically get true fractions
because fractions are inside this font.
| | 04:38 | But remember it's not just the text
that's already there. If I later go in here
| | 04:42 | and edit the text perhaps add a
new fraction, then it will update
| | 04:46 | automatically. For example, I'll
delete that 1 and you can see that now it's
| | 04:50 | not a true fraction anymore, but if
I change it to a 7 it becomes a true
| | 04:54 | fraction. If I come over here and say
22, I get the regular numeral character
| | 04:58 | formatting. slash and then 7.
As soon as I type that 7, InDesign says oh,
| | 05:04 | well that matches my pattern, one or
more digits followed by slash followed by
| | 05:08 | another one or more digits. Looks like
a fraction; let's apply the fraction style to it.
| | 05:13 | So GREP Styles are very, very powerful.
Let me show you one more example of how
| | 05:17 | I use GREP Styles, I use this all the
time. Let's jump over here to page 6 and
| | 05:23 | I'm going to zoom in here to this text.
Bliss No. 5, my company name.
| | 05:29 | So I select it and press Command+4 or Ctrl+4
on Windows. You can see that even here
| | 05:33 | because we assigned numbers in this
Paragraph Style, it's showing up here as well.
| | 05:38 | But I want to apply special formatting
to this whole company name, Bliss No. 5.
| | 05:44 | How do I do it? I'll go back to my
Body text, double-click on it to edit it,
| | 05:47 | hit GREP Style, make a New GREP Style,
and this time I want a special GREP Style
| | 05:53 | that targets just my company name and
it's going to be Bliss No. 5.
| | 06:00 | there is nothing special about this.
It's literally just that text.
| | 06:04 | Anytime that it finds Bliss No. 5, there
is no special codes. Whenever it finds this text,
| | 06:09 | it should apply my special New
Character Style called my company style
| | 06:15 | and once again we'll go and change
this to -- how about something, how about
| | 06:18 | Myriad Pro Semibold? Let's do a
different color now, how about blue?
| | 06:23 | And that looks pretty good.
| | 06:24 | Well, one more thing that I often do
here is in Basic Character Formats,
| | 06:28 | I'll turn on No Break. So my company
name will never break across two lines.
| | 06:33 | It won't hyphenate and it won't break
across lines. It will always stay together.
| | 06:37 | I like that. Click OK, click OK and we
can see that it changed the formatting
| | 06:42 | and No Break was automatically
applied to it. So it will never break across
| | 06:46 | multiple lines.
| | 06:47 | I love GREP Styles. It's an incredibly
efficient way to apply formatting to any
| | 06:51 | pattern of text inside of a paragraph.
| | Collapse this transcript |
| 4. Escape characters| 00:05 | I would like to apply a special GREP
Style to all the dollar amounts in my
| | 00:08 | document. For example, down here in
the lower left corner of this page I have
| | 00:11 | got some dollars here and dollars here.
I would like to apply different kind of
| | 00:15 | formatting to that. So I'm going to go
to the Paragraph Styles panel and
| | 00:19 | I'm going to double-click on this. Just so
it selects it, I see this is Body text,
| | 00:23 | so I'll right-click on it or Ctrl+Click
with one button mouse and say I want a
| | 00:27 | New GREP Style here.
| | 00:29 | The new GREP Style is going to apply a
character style called dollar amounts and
| | 00:34 | we'll change the color just so that's
a easy way to really stand out,
| | 00:37 | you can see that it is different and it's
going to apply it not just to the numbers.
| | 00:42 | Right now it's just the numbers, but I
want to apply it to the entire dollar amount.
| | 00:45 | So how would I do that?
| | 00:48 | Well, you might think that you could
do something like dollar sign, let's say
| | 00:52 | one or more digits and then period and
then remember that if you can't recall
| | 00:57 | the codes for things like digits, you
can always pull them out of these fly-out menus
| | 01:01 | and then pull things out of like Wildcard >
Any Digit. So, easy to do it there as well.
| | 01:06 | So one or more digits here, in fact
this case is just two digits. So one or
| | 01:09 | more digits, followed by a period,
followed by two digits. And you think that
| | 01:13 | would work, but it doesn't. In fact,
if I click off here in the blank area,
| | 01:17 | you can see that it completely fails.
| | 01:18 | Now, none of the digits are being found
at all. Why? Well, the problem is GREP
| | 01:24 | reserves certain characters for its
special codes. For example the dollar sign.
| | 01:29 | The dollar sign means something to GREP.
So GREP looks that and says, well,
| | 01:34 | the dollar sign means end of a paragraph.
Well, we don't want it to mean end of the
| | 01:38 | paragraph. Well, we need to do what's
called escaping it out. We need to tell GREP
| | 01:43 | to stop thinking of this as a code and
start thinking of it as a dollar sign
| | 01:47 | character itself. And the way you do
that is simply by placing a backslash in
| | 01:52 | front of it. So we can do \$ and GREP
says, oh you mean the real dollar sign.
| | 01:57 | Okay, I got it.
| | 01:58 | So \$, \d, which is the code for digit
and then that dot here, the period, also
| | 02:05 | means something. We wanted to mean the
actual period symbol. But GREP says
| | 02:10 | the dot means any character. Any character,
it doesn't matter what it is.
| | 02:15 | It's looking for any character and that's
a problem. So we need to escape it out.
| | 02:18 | Once again, just put a backslash in front it.
| | 02:21 | So it makes it a little bit ugly, \$,
\d and so on. But that is the code for
| | 02:27 | the dollar value itself. I'll deselect
here, and we can see that the code worked.
| | 02:32 | Because the Preview checkbox is on, we
can immediately see that that character
| | 02:36 | style was applied to the full dollar amount.
| | 02:39 | Let's try another one. I'm going to
create a New GREP Style and this case
| | 02:43 | I'm going to create a New GREP Style
for anything inside of parenthesis.
| | 02:47 | So I'll type open parenthesis and then dot
which means any character, right. That's a
| | 02:52 | special code for any character and then
I'll place a plus sign, which means one
| | 02:56 | or more of any characters, and then
closed parenthesis. And the character style
| | 03:01 | I'm going to apply it to is, let's make
a new one for stuff in parens and this
| | 03:07 | is going to be in different colors.
Let's make it Beige and let's make it
| | 03:10 | Myriad something like that, click OK
and we can see that, oh my goodness,
| | 03:15 | what happened? All the text got changed.
| | 03:17 | Well once again, we have a problem
because of special reserved characters.
| | 03:22 | The parenthesis is a reserved character.
So we need to escape it out. How do we do it?
| | 03:27 | Well, we could just put a backslash
in front of it or if we don't remember
| | 03:31 | that backslash trick, we can always
just delete it and come out to the fly-out
| | 03:35 | menu and look for the symbol here and
right inside the Symbols fly-out menu,
| | 03:40 | we can see closed parenthesis character.
There we go. And all it is, is backslash
| | 03:43 | parenthesis. There you go. Now that
should work. Click off of it and we can see
| | 03:47 | that all the stuff in parens
including the parens gets that applied to it.
| | 03:52 | Because this GREP Style comes
after this GREP Style, it overrides it.
| | 03:56 | So it goes down the list in order.
If we want the dollar amounts to be
| | 04:00 | formatted differently then the rest of
it. We can move it down by selecting it
| | 04:04 | and clicking the down button. And now
this comes second, so it overrides the
| | 04:09 | stuff in paren style. I'll show you
one other example of the Escape feature.
| | 04:13 | Let's zoom out here and I'm going to
use Shift+Page Up to come back to page 5 here.
| | 04:18 | And then why don't I zoom in on
just this text so we can see that?
| | 04:22 | I'll just select it and then Command+4 or
Ctrl+4 on Windows, just to zoom into 400%
| | 04:26 | and I can see that I have got a really
wacky bit of text there and I want to
| | 04:30 | find that kind of text
using GREP for some reason.
| | 04:33 | So I could open the Find/Change dialog
box, Command+F or Ctrl+F on Windows and
| | 04:39 | why don't I move this over so I can
see both at the same time and I want to
| | 04:42 | type that into this Find What: field,
of the GREP tab of the Find/Change dialog
| | 04:46 | box. That's (a+b*c?). Well the
problem here is these are all reserved
| | 04:54 | characters, well not a, b and c but
the rest of it is reserved characters. So
| | 04:58 | that's is going to cause me all kinds of grief.
| | 05:00 | Fortunately, GREP has a way to escape
out a whole clause, a whole phrase as it
| | 05:06 | were and the way you do that is
before the phrase, I'm going to place the
| | 05:10 | cursor just to the left of the
parenthesis here and I'm going to do a \Q and
| | 05:15 | then at the end I do a \E and this is
kind of undocumented. You are not going
| | 05:21 | to find this one in this fly-out as far
as I know. I don't think it's hiding in there,
| | 05:24 | but that means escape out all
of this phrase and find exactly that.
| | 05:30 | Let's try it out. I'll make sure my
cursor is up here and then I say Find and
| | 05:34 | boom! it worked. Perfect! Great!
It looked for that and ignored the reserved
| | 05:39 | GREP Codes in there because I escaped
those characters with the Q and the E.
| | 05:43 | Forgetting to escape characters is
one of the common mistakes that you can
| | 05:47 | make when you are creating your GREP
expressions. So whenever something fails
| | 05:50 | and you are troubleshooting it and you
are trying to figure it out, make sure
| | 05:53 | you look at each one of those
characters and ask yourself, do I need to escape
| | 05:57 | that character or is it
actually supposed to be a code?
| | Collapse this transcript |
| 5. Finding how many and how long| 00:05 | I want to find the word chocolate or
chocolates. Either chocolate singular or
| | 00:10 | chocolates plural. So I'll open up
the Find/Change dialog box with a
| | 00:13 | Command+F or Ctrl+F on Windows, and if
I would just search in for chocolate by
| | 00:17 | itself I could do that in the Text tab
of the Find/Change dialog box.
| | 00:21 | But in this case I'm going to be typing a pattern in.
So I'm going to use the GREP tab instead.
| | 00:27 | So I'll type Chocolate and then I want
to say sometimes it has an S on the end,
| | 00:32 | and I don't know which one it's going
to be. So I need to tell InDesign with
| | 00:36 | some kind of special code that
the S may or may not be there.
| | 00:40 | Now the code I'm going to find inside
the @ sign fly-out menu. I'll come down
| | 00:45 | here to Repeat and I'm going to say
this is going to Repeat Zero or One Time.
| | 00:51 | This Zero or One Time code, which if I
selected you can see is a question mark,
| | 00:55 | is a great way to find words or
phrases when a single letter may or
| | 01:00 | may not be there.
| | 01:01 | In this case it will find Chocolate and
then the S could be there or could not
| | 01:06 | be there. Now let's go ahead and come
out here, I'm just going to click out
| | 01:10 | here and zoom into 200% view so we can
see whatever the results are, little bit
| | 01:14 | better, click Find, and there we go.
Chocolate it founded, click again
| | 01:18 | chocolate, chocolate, this is pretty
good, oh, it's finding lots of chocolate,
| | 01:22 | I like chocolate. I'm just going to
keep clicking on here until it proves the
| | 01:26 | point that indeed it will find
chocolates as well. There we go, chocolates,
| | 01:30 | Bliss no.5 Chocolates. So
it found one or the other.
| | 01:34 | Now remember that it's only finding
because it's case-sensitive. So only
| | 01:38 | uppercase C and then Chocolates. If
I wanted to find both uppercase or
| | 01:42 | lowercase I would have to type-in a
different code. Lowercase or uppercase
| | 01:47 | inside square brackets, let's go ahead
and try that. And I'm just going to keep
| | 01:51 | clicking Find, oops, there
we go. There is a CHOCOLATE.
| | 01:53 | Now it looks like it's all uppercase
when here it's lowercase. What's going on
| | 01:58 | there? Well, I can see if I look up in
the control panel here that the All Caps
| | 02:03 | formatting is applied to this. So
this text must actually be or behind the
| | 02:08 | scenes lowercase, but the all caps
is making it look like it's uppercase.
| | 02:13 | Here is another example of when that
question mark code might be useful. Maybe
| | 02:17 | I have the word color in my document,
but sometimes it's the Brit spelling with a U.
| | 02:22 | I put a question mark after it and
now it will find both color with a U or
| | 02:27 | without a U. It could go either way
very, very useful to sort of expand the
| | 02:32 | options of what this will find. I don't
actually have the word color in here so
| | 02:36 | I'm not going to search for that,
instead I'm going to search for a different
| | 02:39 | code, I'm going to search for
everything in parenthesis. But in this case
| | 02:44 | I'm going to zoom back here and go to a
particular page where I know there is going
| | 02:49 | to be a problem. There is
always a problem in here.
| | 02:51 | I am going to go to page 8 here and
zoom into 200%, and I can see that this
| | 02:56 | paragraph has two different sets of
parenthesis. So why is that important?
| | 03:00 | Well, I'll move that out of the way a
little bit. I'll open my Paragraph Styles
| | 03:04 | and I'm going to Edit my Body text style here,
and I'm going to edit it with a GREP Style.
| | 03:09 | I am going to add a GREP Style here,
how about we set this for -- just make a
| | 03:14 | new one, it will be easier, and I'll
say this is going to be Myriad Pro,
| | 03:18 | Regular, let's change its color so it
really stands out here, Beige color,
| | 03:22 | click OK, and it's going to be
everything that is within a parenthesis.
| | 03:27 | So I'll say open parenthesis, and then
pretty much everything that shows up between that
| | 03:33 | and the closed parenthesis. I'll
just type that backslash parenthesis, /),
| | 03:37 | click off here we can see that it
kind of worked and kind of didn't.
| | 03:41 | It applied it to this phrase in here
inside these parenthesis but then it just
| | 03:45 | kept on going, kept on going, kept on
going until this one. Well, this is an
| | 03:49 | issue with GREP. GREP is what's called
greedy. It will always grab as much as
| | 03:54 | it can within a paragraph.
| | 03:56 | Now if you wanted to be less greedy, if
you wanted to just choose the shortest
| | 04:01 | match that it can get in here you need
to choose a different code, and it shows
| | 04:06 | up there in the Repeat fly-out menu,
let's go and take a look, it's good thing
| | 04:10 | that the Paragraph Styles Options
dialog box is still open, I had the Preview on.
| | 04:15 | So I don't even have to go back to
edit it, I simply click on here again. So
| | 04:19 | I'm going edit this code so that it is
less greedy, and the key here is instead
| | 04:24 | of that little plus sign there I'll
delete that, I'm going to say find me
| | 04:28 | everything, the dot means find
everything, any kind of character, but not
| | 04:33 | Repeat One of More Times like I was
using instead I'm going to use it One or
| | 04:37 | More Times (Shortest Match). That
Shortest Match is very, very important in
| | 04:42 | this kind of circumstance, and the
code is +?. So that means grab any
| | 04:48 | characters, the string of characters,
but keep it the shortest match possible
| | 04:52 | before the final parenthesis. I'll
click off here and you can see that now it's
| | 04:56 | working perfectly. It's applying it to
this phrase inside the parenthesis, and
| | 05:00 | this one, but not the text in between.
| | 05:03 | Okay, one more quick repeat trick that
you might want to use. I'll choose a New
| | 05:07 | GREP Style here, and I'm going to make
a new style which is going to be just
| | 05:11 | for my years, anything that looks like
a year, four digits in my document. Why
| | 05:15 | don't I just go ahead and change this.
I'll just change the color to something
| | 05:18 | bright, so we can really see it like
Magenta, click OK, and it's going to be
| | 05:22 | not a string of digits of any length
instead it's going to be only four digits
| | 05:27 | long. Only find me four digit long
characters with no other characters in
| | 05:31 | between like no commas or anything.
The way you do that is you do it {4}, and
| | 05:38 | that means find a string of four any
digits. Any digits, but only four of them
| | 05:44 | in a row. And that's a little
undocumented trick. It's certainly documented in
| | 05:47 | GREP documentation but not in InDesign.
I mean there is nothing inside this
| | 05:52 | fly-out menu that would indicate that
you can do this kind of code. That's one
| | 05:56 | of those things that you
just have to know how it works.
| | 05:58 | I will click OK. I'm just going to go
find that in the text itself, and
| | 06:03 | if I don't find one I better just go ahead
and type one. So I'll just come in here
| | 06:06 | and say 2009 and as soon as I finish four digits
in a row it applies the GREP style to it.
| | 06:13 | When you are typing out a GREP code
it's imperative that you have absolute
| | 06:17 | precision when you are defining the
pattern you are looking for. These Repeat
| | 06:20 | codes like the Zero or One Time or
the One or More Times really help you to
| | 06:25 | find that pattern so you find
exactly what you are looking for.
| | Collapse this transcript |
| 6. Specifying text location in a paragraph| 00:05 | One of my favorite usages for GREP is
to apply Paragraph Styles and Character
| | 00:09 | Styles to text in a long document. For
example in this file I have some lists,
| | 00:14 | and this list is just not consistent.
I guess somebody actually typed 2 and
| | 00:19 | then there is a period, and then a
space, but up here there is a bunch of
| | 00:21 | spaces and down here there is
a number, a period and a tab.
| | 00:25 | So in some cases there are tabs, in
some cases there are spaces. I really wish
| | 00:29 | I could get rid of all of that and
just apply InDesign's automatic numbering.
| | 00:33 | That way I know it will be consistent
and look just right throughout the document.
| | 00:38 | So how can I do that? Well, I'll open
up the Find/Change dialog box with the
| | 00:42 | Command+F or Ctrl+F on Windows and
I'm going to type in a GREP code that
| | 00:47 | defines this pattern. This pattern is
going to be a digit. So I know that's /d
| | 00:52 | and I'm going to say -- actually
there might be more than one digit because
| | 00:56 | maybe it's one digit or maybe it's
ten or eleven, maybe it's more than one digit,
| | 00:59 | and I think that it has a little
dot after it. Most of these seem to
| | 01:02 | have a period, but I know that
the period code means any character.
| | 01:07 | So I need to escape it out.
| | 01:09 | I will press the left arrow key on my
keyboard and put a \ before it. So this
| | 01:14 | means a period itself, look for that
actual character. Now it might be there or
| | 01:18 | in some cases it might not be there.
Maybe they forget to put in. So I'll put a
| | 01:22 | question mark. So that says
this period may or may not be there.
| | 01:25 | Now their may or may not be a space
there. So I'll do a \s, and there is
| | 01:30 | probably one space or two spaces, or
I don't know how many, let's go to the
| | 01:34 | fly-out menu and choose Repeat Zero or
More Times. So it might be there or it
| | 01:40 | might be one, two, three... we don't
know, and that's the asterisk code.
| | 01:44 | So that's looking pretty good. That
seems to define the code we are looking for.
| | 01:48 | Let's try it. I'll click Find and
we can see it found that 5. That's good.
| | 01:52 | Find Next and that seems to work there.
Uh-oh! That's not working at all.
| | 01:57 | What happened? It found a number right in
the middle of a paragraph. Well, it was a
| | 02:02 | number and it was followed by a space,
but that's not something we want to find.
| | 02:06 | We need to define the GREP code even further
and specify exactly what we are looking for.
| | 02:12 | In this case we need to tell the GREP
code to only consider numbers at the
| | 02:16 | beginning of a paragraph.
| | 02:18 | So I'll place the cursor before that
initial backslash. I'm going to go out to
| | 02:22 | this little @ sign fly-out menu and
I'm going to give it a Location. The
| | 02:26 | Location pop-out menu offers me five
choices, Beginning of Word, or End of
| | 02:31 | Word, or right out of Word Boundary.
In this case we want to use Beginning of
| | 02:35 | Paragraph and only Beginning of
Paragraph, which is the caret symbol.
| | 02:39 | So this pattern has to be at the
beginning of a paragraph. Let's try it out.
| | 02:44 | Click Find Next, and it finds it,
click Find Next, and it finds it. So this
| | 02:48 | seems to be working just right. Now
what do we want to do to this GREP pattern.
| | 02:52 | Well, we want to apply a paragraph
style to it. So I'm going to do click down
| | 02:56 | here in the Change Format field,
brings up the Change Format Settings dialog
| | 02:59 | box and I'm going to say I want to
apply my numbering list Paragraph Style to
| | 03:05 | anything that matches this style.
| | 03:07 | Let's go ahead and click Change All
and see what happens. It went through my
| | 03:10 | whole document and it seemed to work
but I didn't quite work the way I wanted it to.
| | 03:15 | It applied the style, that's great,
but it did not get rid of the text that
| | 03:20 | it found. I still have this 8
period space, space and so on.
| | 03:24 | So I wanted to get rid of it, and I
left to Change To field blank so you would
| | 03:28 | think that it would delete it, right?
Well, true except that there is this
| | 03:33 | little i here. That i means that this
formatting applied to it and when you
| | 03:37 | have Find What filled, Change To blank
but the i here, some format applied to
| | 03:43 | it, that means go ahead and leave the
text there. So in order to make this work
| | 03:47 | I need to do one more little thing.
I need to search for one additional
| | 03:52 | character. I'm getting ahead of myself
here a little bit but I'm going to let
| | 03:55 | you in on a secret and that is, I can
take text from here and put it down here
| | 04:01 | if you put it in parenthesis. And the
text that I'm going to take is any single
| | 04:05 | character. That period means any
single character that it finds.
| | 04:10 | And because it's in parenthesis I
can put that character down here with a
| | 04:14 | special code and that code is $1. Now
dollar sign up in the Find What field
| | 04:21 | means it's a Location tag, it means
only find it at the end of a paragraph.
| | 04:25 | That's what dollar sign means. But
dollar sign down here in the Change To
| | 04:28 | field means something very different.
It means take whatever was up here inside
| | 04:33 | this parenthesis and put it down here
in the Change To field automatically.
| | 04:37 | All right, so I'm going to Undo this,
Command+Z or Ctrl+Z to go back to where I was,
| | 04:42 | and now we'll try it one more
with this extra code. One more time it's
| | 04:46 | going to search for at the beginning
of a paragraph, look for one or more
| | 04:49 | digits followed by maybe a period,
maybe not, followed by maybe some space,
| | 04:54 | maybe not, followed by anything. And
then take that anything and put it down
| | 04:58 | here and while you are at it format the
whole paragraph. Will it work? With one
| | 05:03 | click we can see that it formats the
entire document quickly. We have deleted
| | 05:08 | the text that we didn't want there
and applied the paragraph formatting.
| | 05:11 | Now let's take our new found
knowledge of setting location to do one more
| | 05:16 | search here. I'm going to delete these
and start from the beginning. I want to
| | 05:20 | find only whole words that begin with
c and end with e. So I'm going to say c
| | 05:25 | and e, I know that's there. I know
that there is any lower case character in
| | 05:30 | the middle so that's going to be
\l with a plus. So one or more other
| | 05:34 | characters between the c and the e,
but not just any c followed by some letters
| | 05:39 | followed by e. Only ones where the c is
at the beginning of the word and e is at the end.
| | 05:44 | So to do that I place my cursor before
the c, I can say at the beginning.
| | 05:49 | At the beginning is going to live in the
Locations pop-up menu and we could use
| | 05:53 | either Beginning of Word or Word
Boundary, either one works. I'll choose Word
| | 05:57 | Boundary here, and then I'll put
another Word Boundary over here. So it says at
| | 06:01 | the Word Boundary start with the c.
At the other end of the Word Boundary end
| | 06:05 | with an E. Let's try it. Click Find
and it finds Chocolate, Find again,
| | 06:10 | chocolate. Find again, and it keeps,
oops. There is another one, starts with a
| | 06:14 | c and ends with an e, but it's not
chocolate. So I know that my pattern worked.
| | 06:18 | If you don't specify a Location
code for your GREP code it will find it
| | 06:21 | anywhere, in the middle, beginning, end
of a paragraph, you don't know where.
| | 06:25 | But when you put those codes in
that's you specify exactly what you want to
| | 06:29 | find and where you want to find it.
| | Collapse this transcript |
| 7. Reusing, recycling, and reordering| 00:05 | I was once working on a book project
that had a lot of historical dates in it
| | 00:09 | like 1492. So I send the manuscript in
and when it comes back from the editor
| | 00:14 | all of those dates had commas in them.
Like suddenly it became 1,492.
| | 00:20 | I was flabbergasted. What I'm supposed to do
with that? I actually had to go through
| | 00:24 | and fix every single one of those dates
removing just the comma, and that would
| | 00:28 | have been a nightmare without GREP.
| | 00:30 | Now this is not the document I was
working on. But it has the same problem.
| | 00:35 | All of the years have commas in them, and
I'm going to show you how I can use GREP
| | 00:39 | to remove just those commas.
| | 00:41 | To do this I'm going to open the Find/
Change dialog box with a Command+F or
| | 00:45 | Ctrl+F on Windows, and I'm going to
type in the GREP tab. The code I'm looking
| | 00:50 | for is a year and years are going to
be based on numbers. So I need an any digit.
| | 00:55 | That's \d, any digit code.
| | 00:58 | In this case I know the first digit
is followed by a comma, so I'll type a comma,
| | 01:02 | and then I could just do three
more of these digits. There is the number
| | 01:06 | digit followed by a comma and three
more digits. There is one problem here and
| | 01:11 | that is that this will find any four-
digit number that has a comma, and the
| | 01:14 | ones I want only come after dates.
And I happen to know that in this document
| | 01:19 | all the dates are something
like March 4th and then the year.
| | 01:23 | So I'm going to go to the beginning of
this GREP code and I'm going to put in
| | 01:27 | another digit followed by another
comma and then a space, because I know that
| | 01:31 | this will find all the instances where
its a date and then the date of the month
| | 01:36 | followed by a comma and then the year.
Let's try it out. I'll click Find and it
| | 01:41 | jumps right to the first instance.
Find Next and it goes to the next. Pretty good.
| | 01:45 | But now here is the problem. I need to
take all of these except the comma and
| | 01:50 | put them into the Change To field.
Whenever you want to take text that's set up
| | 01:53 | as a wild card in the Find What field
and put it in the Change To field, you
| | 01:57 | have to put it in parenthesis.
| | 02:00 | So for example, I'll put a parenthesis
before this first digit and the first
| | 02:04 | comma and that space, because I want to
save all of that, and I'm going to put
| | 02:09 | it down here with $1. Whatever is the
first instance of the parenthesis gets
| | 02:14 | put into what's called $1 GREP code.
| | 02:18 | Now I'm going to grab the second digit
that I want which is the first digit of
| | 02:23 | the year and I'll put that down here as
well, with a $2. The second parenthesis
| | 02:29 | is a $2. Now I don't want that comma
there but I'm going to grab it anyway, and
| | 02:34 | then I'll grab that final chunk, the
last three numbers in here and I'm going
| | 02:40 | to put that down here with $4.
| | 02:43 | So I want 1, 2 and 4, but I'm leaving
out 3, which is the comma. I notice that
| | 02:48 | in the Change To field the little eye
icon is here which draws my eye down to
| | 02:52 | the bottom and I can see it has some
formatting applying to it. Always be
| | 02:56 | careful of that little eye when you do
not want to apply formatting, in this
| | 03:00 | case I certainly do not.
| | 03:01 | So I'm going to click on the Trash Can
icon to make that go away. Now let's go
| | 03:05 | ahead and try it. I click Change All.
It went to the whole document and in one
| | 03:10 | click it changed all the years
throughout the entire document, 55 of them much
| | 03:15 | faster than it would have been by hand.
| | 03:17 | Okay this is great. Now let's go
ahead and do something a little bit more
| | 03:20 | tricky. Let's reverse the order of
these names. I want the last name first.
| | 03:24 | I want this to be Monroe, James. Adams,
John Quincy. Can we do that with GREP?
| | 03:30 | Sure no, problem.
| | 03:31 | Let's start over. I'm just going to
delete these, and I'm going to type in some
| | 03:35 | codes that will find those names. The
first thing I know about these names is
| | 03:40 | that they are at the beginning of the
paragraph. So I'll go to the flyout menu
| | 03:43 | here, go to Location pop-up menu and
say this is going to be starting at the
| | 03:47 | beginning of the paragraph. Then I
need to define what it is that I'm looking for.
| | 03:51 | I'm looking for something that
looks like a name, and I'm going to put it
| | 03:54 | in parenthesis because I know that
I'm going to be wanting to use later.
| | 03:57 | So I'll open the parenthesis and then
I'm going to find something that's a wild
| | 04:01 | card called the Any Word character.
Any Word is like an uppercase or a
| | 04:05 | lowercase character or a number, lot
characters fall into the category of
| | 04:09 | letter that might be in a word. That's
\w, and I'm going say there is going to
| | 04:13 | be one more of those.
| | 04:15 | I know that this word is always going
to be one or more characters. The Space
| | 04:19 | character however never fits into the
word. So this will not match that first
| | 04:23 | space character. It will go up
to the end of the first word.
| | 04:25 | Now I have got a problem because in
some of these cases I have got James
| | 04:29 | Monroe, which is two words, and in
some I have got three words, John Quincy
| | 04:33 | Adams, and in some I have like Ulysses S.
Grant. So there is an initial in the
| | 04:38 | middle. I need to be able to search for
all of those and handle them properly.
| | 04:41 | I know that I'm going to be needing
whatever it is that I'm capturing later, so
| | 04:45 | I'm going to just start with a new open
parenthesis here and I'm going to type
| | 04:48 | in a code for any of those things
that might appear and it's going to be an
| | 04:52 | either or situation, so I'm going to
use a square bracket. It's going to be
| | 04:56 | something inside the square
brackets, which means this or that.
| | 04:59 | I know it might be a space there or
maybe there is a individual word character
| | 05:04 | like \w or maybe there is period, and
because its inside one of these square
| | 05:09 | brackets I don't have to escape it with
a backslash. I'll just leave that as a
| | 05:13 | period. So it could be any of those
things coming next. And I know that there
| | 05:17 | may be more than one of them, so I'll
put the plus sign there. So this is going
| | 05:21 | to be one or more of either
a space or a word or period.
| | 05:25 | Now I'll close that parenthesis
because that's going to close the next little
| | 05:29 | chunk that I'm going to using later.
But is that chunk always going to be
| | 05:32 | there? Well in the case of a two-word
name it's not going to be. All I want is
| | 05:38 | the first and the second piece,
there is nothing in between.
| | 05:41 | So in this case I'm going to put a
question mark after that little chunk of
| | 05:45 | code there. So this whole parenthesis
might be there or it might not be.
| | 05:50 | What I do know is always there is a space.
There is always going to be a space between
| | 05:54 | these two characters. So I just type
a space here in the Find What field.
| | 05:58 | And now for the last name. The last
name is going to be pretty much the same as
| | 06:02 | the first. Any word space more than
one but it always is going to be followed
| | 06:08 | by a comma. So I'll just type a comma
in there, and then close my parenthesis.
| | 06:12 | It looks complex but let me just go
over it one more time. Beginning of the
| | 06:16 | paragraph any word with one or more
characters followed by a word that may or
| | 06:21 | may not be there which is going to be
either a space or a word character or a
| | 06:27 | period character. All of those things
are going to be the second name and then
| | 06:31 | when, again, it may or may not be
there and then finally a space and another
| | 06:34 | word followed by a comma.
| | 06:36 | And that matches this pattern perfectly.
That was the hard part. Once I have
| | 06:40 | got the GREP code, now I just have
to put it back in the right order. So,
| | 06:44 | I'm going to say Change this to 3 because
that's the third thing in the parenthesis
| | 06:49 | as the last name and I want to start
with my last name. So I'm going to say
| | 06:53 | start with $3 then put a space in
there between the names and then say do the
| | 06:58 | first one first name and the second name.
| | 07:01 | No space between 1 and 2 because if
there was one it would have been captured
| | 07:06 | by this second element here. But at the
end after 2 I do need a comma, because
| | 07:10 | I want to make sure that this is
followed by a comma before it goes into
| | 07:13 | the rest of the line.
| | 07:15 | Okay let's try it out. I'm going to
search the entire document and with one
| | 07:18 | click I say Change All, it goes through
and the all the names are reversed.
| | 07:23 | So sure, using GREP codes to find text
and maybe applying formatting to it is pretty cool.
| | 07:28 | But being able to actually
move the text around? That is awesome!
| | Collapse this transcript |
| 8. Finding between| 00:05 | I want to find all the ordinal numbers
in my document like 3rd or 4th and apply
| | 00:09 | superscript formatting to that rd or
the th after the number. Of course,
| | 00:14 | I don't want to apply superscript to
all the rd's and th's throughout my
| | 00:17 | document. That would be crazy.
Just the ones that follow the numbers.
| | 00:21 | Well, can we do that? Sure, not a problem
at all if we are using GREP styles.
| | 00:25 | So I'll open my Paragraph Styles
panel and I'm going to right-click or
| | 00:29 | Ctrl-click with a one-button mouse on
Body and then Edit "Body". I'll jump over
| | 00:33 | to GREP Style, add a new GREP style
and I'm going to apply a new style and
| | 00:38 | I'm going to call this my ordinal
superscript style and I'll come over and
| | 00:43 | say this is going to be a
Superscript Style, OpenType superscript.
| | 00:48 | I'll click OK and now I need to
define what's going to get that superscript
| | 00:52 | applied to it. Right now it's every
digit in the document. Of course that's not
| | 00:56 | what I want. What I want is th's or
rd's and I put that vertical bar between
| | 01:03 | the two and I'm going to put those in
parenthesis just to kind of hold those
| | 01:06 | together as a unit.
| | 01:08 | Now again I don't want any rd or any
th. I only want ones that are after a
| | 01:13 | number and I don't want it to apply to
the number as well. For example if I put
| | 01:18 | a digit here, any digit then ordinal
superscript would also apply to the digit.
| | 01:22 | Well that doesn't work. So when I
delete that and instead I need to say to
| | 01:27 | InDesign, "look behind these letters"
and in fact that's the name of the GREP code.
| | 01:32 | It's called a Positive Lookbehind
and I could find that in the Add pop-up
| | 01:37 | menu here. Down in the Match sub-menu
there is this thing called a Positive Lookbehind.
| | 01:43 | That means if there is something
behind this text then go ahead and apply the
| | 01:47 | style and if it's not there, then
don't apply the style. You'll notice that
| | 01:51 | there is also a Negative Lookbehind
and a Positive Lookahead and I'll be
| | 01:54 | looking at this one in just a minute.
But in this case I'm going to use a
| | 01:58 | Positive Lookbehind.
| | 01:59 | Now it's a little frustrating because
the code is entered but the cursor does
| | 02:03 | not end up where it needs to be for me
to type what I'm looking for. Instead
| | 02:07 | I need the cursor just one character to
the left, in between the equal and the
| | 02:12 | parenthesis, and here is where I need
to tell InDesign what I'm looking for,
| | 02:16 | what's behind the th or rd. And
that's going to be a digit just in number.
| | 02:21 | I am looking for any digit followed by
a th or rd and when it finds this, apply
| | 02:27 | the superscript to it. Let's click off
here and I'll move this out of the way
| | 02:32 | and we'll be able to see a in little
tiny letters here. There is a th after 18.
| | 02:37 | I'll click OK, zoom in here so we can
see it a little bit better, here we go, 18th.
| | 02:42 | Now I can find more of them by
pressing Command+F or Ctrl+F and open the
| | 02:46 | Find/Change dialog box and I'll just
look for any digit followed by a th, say.
| | 02:50 | Click Find, it finds that one,
find it again. There we go June 5th.
| | 02:55 | So it automatically is applying the
correct style to the th or rd but only
| | 03:00 | after a number. Here we go, there is
an rd 23rd, so it applied it correctly.
| | 03:04 | Now what if I wanted to apply
formatting to anything inside parenthesis, not
| | 03:09 | the parenthesis themselves but only
stuff inside parenthesis. Well again we can
| | 03:13 | do that with GREP styles.
| | 03:15 | I'll edit my Body style and I'm going
to go to the GREP style and I'll create
| | 03:18 | another GREP style in this case I'm
going to apply a new style. I'll just leave
| | 03:22 | it Character Style 1, it doesn't
matter but this one's going to be Myriad
| | 03:25 | Regular and let's go ahead and apply a
color to it so we can see it a little
| | 03:29 | better, maybe this burgundy color.
Click OK and we don't want it applied to
| | 03:34 | digits. I'm going to apply this
to anything in between parenthesis.
| | 03:36 | So I'm going to start with my open
parenthesis character and I know I'm going
| | 03:41 | to ending with a closed parenthesis
character and in between those I'm going to
| | 03:46 | be finding pretty much anything. Let's
say a wildcard, let's say Any Character,
| | 03:50 | and I don't know what's going to be in
there and I'm going to Repeat it let's
| | 03:54 | say One or More Time(Shortest Match
). So just the stuff that's in between
| | 03:59 | parenthesis, but the problem here is
it this code finds the text inside the
| | 04:03 | parenthesis and includes the parenthesis.
| | 04:06 | That's not what I wanted, what I
wanted was only the stuff in between the
| | 04:10 | parenthesis. I can do that with a
Positive Lookbehind and a Positive Lookahead.
| | 04:15 | So instead I'm going to delete this
parenthesis and I'm going to use my flyout
| | 04:20 | menu here. Let me go grab my flyout
menu. That will place my cursor just the
| | 04:24 | right place, just before all of that
and say Match Positive Lookbehind and
| | 04:29 | between equal and the parenthesis I'm
going to put a backslash parenthesis.
| | 04:32 | Remember that escapes the parenthesis character.
| | 04:35 | So it's going to be the opening
parenthesis is behind the text I'm looking for
| | 04:40 | and now I need one more of these Match
Positive Lookahead and in between the
| | 04:45 | equal and the parenthesis I need
to have a escaped closed parenthesis
| | 04:50 | character. So one more time this means
any character.+?, it's going to be any
| | 04:56 | character with a shortest match in
which behind it is a open parenthesis and
| | 05:02 | after it is a closed parenthesis. Click
off of it, Preview is on, so we can see
| | 05:07 | that it worked.
| | 05:08 | It only found the stuff that was
inside parenthesis. Of course, this doesn't
| | 05:13 | have to be parenthesis, we could
remove this and put let's say quote marks in
| | 05:17 | instead. I'll put a double quote there
and I come over here and put a double
| | 05:20 | quote here and now it's just going to
find stuff that's inside quotes. I don't
| | 05:24 | see anything right now but no problem.
I'll just come up here, let's say quote
| | 05:29 | here and quote here and suddenly
anything that's in between those quotes gets
| | 05:34 | that Character Style applied to it,
and it's totally on the fly,
| | 05:38 | totally automatic and totally great.
| | 05:40 | So as soon as I close that quote mark,
it applies the character formatting
| | 05:43 | automatically for me and that is
great. It is so much more efficient than
| | 05:47 | having to find these things manually.
| | Collapse this transcript |
| 9. Using GREP with fonts| 00:05 | In this document, I can see that the
logo for the store Bliss No. 5 has a
| | 00:10 | circle around the 5. When I zoom in on
the text up here, I see that there is no
| | 00:14 | such circle on these 5s. But wouldn't
that be kind of cool to have a little
| | 00:19 | text treatment here where the 5 has a
circle around it? I'm going to show you
| | 00:22 | how I can use GREP Styles
to put that circle there.
| | 00:25 | The first thing I'm going to do is
replace that 5 with an n. Why an n? Well,
| | 00:31 | I just happen to know that in the
Wingdings 2 font the n looks like a 5 with a
| | 00:37 | circle around. I just happen to know
that. So I'm going to replace the 5 with
| | 00:42 | an n here. So I'll open my Paragraphs
Styles panel and I'll double-click on the
| | 00:46 | Body style to create a new GREP Style.
Select the GREP Style tab,
| | 00:51 | now I'll click New GREP Style.
| | 00:53 | You can see I already have a couple of
GREP Styles in this Paragraph Style, but
| | 00:57 | I'm going to create a new GREP Style,
which will apply a new Character Style
| | 01:01 | called let's say wingdings, might as
well, and this is going to apply the
| | 01:06 | Wingdings font. Actually Wingdings 2 to
be precise. Maybe make it a little bit
| | 01:11 | bigger than the text around it,
something like that and click OK.
| | 01:15 | Now, I don't want this to apply to that
numbers in here. I want it to apply to
| | 01:19 | the letter n but not just any n.
Only n's that comes after an o. right?
| | 01:25 | So I'm going to use a Positive Lookbehind
and it's going to look for the text no.
| | 01:33 | and of course I need to escape that
period out with a backslash and then it's
| | 01:36 | going to search for the character n.
We can test this out by turning on the
| | 01:41 | Preview checkbox and immediately you
see that what was an n is now a 5 with a
| | 01:47 | circle around it. So this is pretty cool.
Because now any time I want to use
| | 01:50 | that logo, that little type treatment,
I can simply replace the 5 with an n.
| | 01:55 | Let's see another example of this.
| | 01:56 | I will zoom back out to this spread in
window and I'm going to jump to the next
| | 02:00 | spread in this document and zoom in
to 400% on this text in the lower left
| | 02:05 | corner. Now, this is an interesting
problem because in this particular font,
| | 02:09 | the l, it's a lowercase l and the
number 1, the digit 1, look very, very similar.
| | 02:15 | I can't even tell the difference
between these. So is this 1lb or llb,
| | 02:20 | or I don't know what.
| | 02:22 | So I'm going to actually use GREP
Styles to change the number 1 into a
| | 02:27 | different font that looks similar, but
is different from the lowercase l.
| | 02:31 | Let's go ahead and do that. I'll double-click
on this Paragraph Style now, go to GREP
| | 02:34 | Style and create a new GREP Style,
which is going to be a style which applies
| | 02:40 | let's say Myriad for 1, for the digit 1.
| | 02:43 | All I'm going to do here is apply
Myriad Pro to this particular character and
| | 02:49 | the character that I want is not all
digits, just the digit 1. It's easy.
| | 02:53 | I just have to type 1 in here and it
will just look for the number 1 to apply
| | 02:57 | Myriad to. Let's go ahead and click OK
and we can immediately see that that's a
| | 03:01 | 1 and that's an lb, this is a 1.
I also see that there is an error in here
| | 03:06 | because this was supposed to be all
digits, 5 digits, and someone snuck in a
| | 03:11 | lowercase l instead. So I'll
hit 1 and that cleans it up.
| | 03:15 | So you can see that using GREP Styles
to apply a different font to one or more
| | 03:19 | characters can really save you a lot of time.
| | Collapse this transcript |
| 10. Making text disappear| 00:05 | What if you want some of your text to
be visible, some of the time and then
| | 00:08 | sometimes you want it hidden? Well,
InDesign CS4 has a cool feature called
| | 00:12 | Conditional Text. And you can find that
in the Conditional Text panel by going
| | 00:16 | to the Window menu choose Type &
Tables and then choose Conditional Text.
| | 00:20 | I am going to create a new condition
in here by clicking on a New Condition button.
| | 00:25 | And then I'll just name this
condition which speech. How about that?
| | 00:29 | Click OK and it shows up here. And I could
apply that condition to each one of these
| | 00:33 | pieces of text, by selecting it and
then clicking on it and then going to the
| | 00:36 | next line and next line but that
would be really, really, really tiresome.
| | 00:40 | Instead, I want to apply it quickly
and the best way to do this is with a
| | 00:44 | Find/Change. But because some of these
are First Inaugural and some are Second
| | 00:48 | Inaugural and some have no First or
Second before them. The only good way for
| | 00:51 | me to do that is with a GREP expression.
| | 00:54 | So what I'll do is I'll open the Find
/Change dialog box with Command+F or
| | 00:57 | Ctrl+F on Windows. Let's bring this up
a little bit. And I'm going to make sure
| | 01:01 | I'm in the GREP tab and I'm going to
look for one or the other thing. Let's say
| | 01:04 | it might start with First, it might
start with Second, I don't really know.
| | 01:09 | It might just start with Inau. So I'll
just start with any of those. It's going to
| | 01:13 | start with one of those and then it's
going to be one or more characters.
| | 01:17 | Let's say the period and then plus. One or
more characters and it's going to always
| | 01:21 | end with the word Address. So why
don't I just say ress in here?
| | 01:25 | That will probably grab it.
| | 01:26 | In fact, I'm also going to grab the
comma afterward. And all of those things
| | 01:31 | First, Second, or Inaugural Address
followed by a comma I want to have a
| | 01:35 | condition applied to it. So I can do
that down here in the Change Format field.
| | 01:39 | I'll just click anywhere down in that
field. Switch over to the Conditions pane
| | 01:43 | and then turn on which speech. So
which speech condition will be applied to
| | 01:49 | anything that matches that. Let's try
it out. Click Change All. Went to the
| | 01:54 | document almost instantaneously. Click
Done and we can see that all of these
| | 01:58 | now have little blue underlines. It's
blue because that's the color of this
| | 02:03 | particular condition. All right. So now
it's visible, but to make it invisible
| | 02:07 | all we have to do is Turn Off the
Condition and they all disappear. All right.
| | 02:11 | Let's try another cool trick for how
to make text disappear that doesn't
| | 02:15 | involve Conditional text. In this case,
I'm going to go through and look for
| | 02:19 | all the words that say Saturday and
I'm going to abbreviate them Sat. I don't
| | 02:22 | know if I would really want to do this
particular thing to this document. But
| | 02:26 | let's say that's what my art director
told me to do, so I'm just following
| | 02:29 | directions. Saturday should be Sat.
I'm not going to truly get rid of the
| | 02:34 | urday, but I want to hide it. I could
do it with Conditions, but I'm going to
| | 02:39 | show a different kind of fun little
trick that you might be able to use for
| | 02:42 | this sort of thing or any other
time that you want text to disappear.
| | 02:46 | I am going to do this with GREP
Styles. So in the future, if I ever type
| | 02:49 | Saturday it will automatically
update and abbreviate. And I'll do that by
| | 02:53 | double-clicking on List of dates.
All of these have the List of dates,
| | 02:56 | Paragraph Style applied to it. And I'm
going to add a GREP Style to it. And the
| | 03:00 | GREP Style is going to simply look for
that text, the urday. So I'll type that
| | 03:06 | in urday. But it's only going to find
it if it's after the Sat. So I better put
| | 03:12 | a Match, Positively
Lookbehind Sat, something like that.
| | 03:15 | Okay, Saturday but it's going to find
the urday. So what do I want to do with
| | 03:20 | that. I want to make it disappear. So
I better make a Character Style that
| | 03:24 | makes text disappear. I'm going to call
this the disappear Character Style and
| | 03:29 | here is how I make text disappear in
InDesign. I'm going to set the Size of
| | 03:33 | this text to 1. Really tiny. All
right. I'm going to go to the Advanced
| | 03:38 | Character Format and I'm going set the
Horizontal Scale to 1%. So really tiny
| | 03:42 | and very, very, very narrow. It's
almost completely gone now. But there is one
| | 03:47 | more thing I would like to do and that
is set the Character Color to None. It
| | 03:50 | will fill it with none. And
something that's filled with none, you simply
| | 03:54 | cannot see it at all. That is
going to make it completely disappear.
| | 03:58 | Because the Preview checkbox is turned
On, I can see that immediately all of my
| | 04:02 | Saturdays have become abbreviated Sat.
The urday is gone. Click OK. And we can
| | 04:08 | test this out. I'm going to select this
word Thursday and change it to Saturday
| | 04:12 | and I'll type the letters, but as soon
as I type the Y it disappears. Because
| | 04:17 | the text really is there, but
it's disappeared with our GREP Style.
| | 04:22 | Disappearing text isn't something you
need to do everyday but when you need it
| | 04:26 | GREP Styles and the GREP Find
and Change are there for you.
| | Collapse this transcript |
|
|