Skip to Content
GREP in InDesign CS3
book

GREP in InDesign CS3

by Peter Kahrel
October 2007
Intermediate to advanced
47 pages
1h 12m
English
O'Reilly Media, Inc.
Content preview from GREP in InDesign CS3

Repeat: Sequences of Characters

In InDesign CS2, to replace sequences of space characters with just a single space, you had to repeatedly replace two spaces with one until there were no more double spaces left. In CS3, there is a much better method: search any sequence of more than one space and replace with a single one: find \x{20}\x{20}+ and replace with \x{20}. As we've seen earlier, the plus is a repeat character and means "at least once," so that the expression paraphrases as "find a space followed by a sequence of at least one space." There are several repeat characters; they're all in the Repeat flyout (see Figure 7).

Repeat options

Figure 7. Repeat options

? Zero or One Time

To find British and American spellings of, say, harbour, search for harbou?r, which finds harbour and harbor. The scope of ? is just one character, so in this example it applies only to the u. The expression paraphrases as "find harbo, perhaps followed by u (or, followed by zero or one occurrence of u), followed by r. To extend the scope of ? to more characters, group them with parentheses: (19)?\d\d finds all two-digit numbers, as well as four-digit numbers whose first two digits are 19. You can combine this with alternation: (18|19|20)?\d\d matches two-digit numbers, as well as four-digit numbers that begin with 18, 19, or 20.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

GREP in InDesign

GREP in InDesign

Peter Kahrel
Running Mac OS X Tiger

Running Mac OS X Tiger

Jason Deraleau, James Duncan Davidson

Publisher Resources

ISBN: 9780596517069Errata