Lesson 06: Found Text -(private link)

  • Sumo

Quick Takes

TL;DR

Full Text (raw transcript)

Up until now, we’ve mostly just been finding the expressions. Now it’s time to do something with that text since we’re still working in the Find/Change dialog box. We can do things like add, delete, rearrange and otherwise style the text that we find with our expressions. In the previous lesson, we found the word that came right before any question mark. So let’s go ahead and style that text by adding a color to it. I’ve set up a character style just called Red, and we’re going to apply that character style to the text that we find going to make sure I have just this story selected and I’m searching only this story.

And I’m being told that I want to find any word character one or more times when it comes before a question mark. So that’s a positive look ahead to a question mark. And let’s actually zoom in so we can see what we’re doing here. Backslash question mark. So now when I say find next, it finds that word. But now we want to change the format. So I’ll come down here to the change format field and click in it.

Choose the character style read. Say, okay. And then we’ll go ahead and change everything in this story. Says three replacements were made and we can see those three places that it changed that word to read. I’m going to do that because I want to do something a little different this time if I don’t have anything in the change format and nothing and change too. And I say change all. It changes it. But what it did was delete that word that was there.

That’s not what he wants. I’m going to undo that. Sometimes I need to tell it to take the text it finds and put it in its place. I’m gonna go to the secret menu under found and we have something called found text. And that gives us dollar signs. Zero. Now, in this case, if I say change all, it’s going to change it. But nothing happened. Or at least it looked like nothing happened. That’s because it found the text and replaced it with itself.

Sometimes you need that to tell it to replace what’s there. So we can add something else. So in this case, I’m going to say replace it with that text. But I also want to add something else to it.

I’m going to undo that. I’m going to keep the expression that’s here. I still wanted to find the word before the question mark. But I also want to add something else to it. I want to add the word question, actually, space. And then the word question in brackets just so I can kind of tag it. Know that that’s a question that’s here. Now, if I leave it like this, it will replace whatever word it finds with the word question.

What I need is it to find everything that fits that pattern, replace it with itself. And then also add this to replace the text with the found text. I want to come over here to the secret menu and go under the found menu to found a text and that puts in dollar sign 0. And that just means replace it with the text that’s found in the pattern. So it’s going to find the word replace it with the word. And it’s also going to put space question afterwards and we’ll go ahead and change the format to to the color.

Just we can see the changes that are made. LSA change all. And now it leaves the word that’s there. It adds that word question afterwards. Now what if you want to remove some text or rearrange that text? That’s where something called sub expressions come in, in our phone number example. We have to use sub expressions because we have some text that’ll disappear like dashes, spaces, dots, etc. And we also want to add some text the dots in between each of the numbers.

So we have to be able to sort of offset all the different components so that we can tell InDesign which bits to keep in which to throw out. So let’s look just at the beginning of this expression. We know we have some or not expressions here. Maybe there’s an opening parenthesis here. Maybe there’s a dash, maybe there’s a closing parenthesis or a space or a period. But what we do know is there that we need to keep these sets of numbers, three, three and four numbers.

Each of those sets of numbers is offset by parentheses. I know it’s hard to tell because there are a lot of parentheses, but this parentheses backslash D three in the brackets and parentheses is a sub expression. And basically that’s a group that says there are three digits here in this number. So there’s a group of three, a group of three and a group of four.

And because each of those are offset, we number each of those groups. This is group number one, group number two and group number three. And by offsetting those, they become sort of this unit that I can move around down here. I have dollar sign one. If I had gone into the found text menu. I can see that I can have up to nine of these sub expressions. So found group number one would give me dollar sign one.

So basically I’m saying take all this other stuff that may or may not be here. And because I don’t assign a group to it, there’s no way to put it back in the change to. And it just sort of disappears. What will remain is group number one, two and three. One, two and three and the dots down here are the dots that I’ve added that I want to appear in between those groups. So when I tell it, group number one, followed by a dot, followed by group number two, followed by a dot, followed by group number three.

And we do a search on this particular story and say, change all. It rearranges it in that order. Let’s undo that. I could even come back to here and get rid of this first group, which is the area code and the first dot. So now I just have a seven digit phone number here. Say change all. Or I could even rearrange those, let’s actually undo that. I could even at the end, for whatever reason, I could put group number one at the end so my area codes will come after the phone number.

Those is the area codes. This is one of the advantages of working with the Find/Change dialog box we can offset into sub expressions and rearrange them and add items and even drop off items that we don’t want to appear anymore. In the next lesson, we’ll take a look at building grep styles into a paragraph style.