Find/Change (Multiple Date Changes in one Find) - InDesign CS5 or earlier

AndrewSipe's picture

ID geniuses, got a question for your gigantic brains.

This may or may not be an easy one...

I doing a lot of production work now and I'd like to create a Find/Change or a GREP search that will allow me to change multiple dates at once.

the format changes from file to file and usually follows these 4 formats and its also possible that all 4 formats could be used in one document.

XX/XX/XX (8 characters)

XX/XX/10 (8 characters)

XX/XX/2010 (10 characters)

9/26/10 - wrong date in-place. (6 – 8 characters depending on the month)

Instead of having 4 different searches, is it possible to do one search that look for any/all of these text formats and change them at once?

Thanks!

AndrewSipe's picture

Well of course, as soon as I post this, I get a response from another site.

Of course GREP comes to the rescue. Enter this in your search field:

\b((XX|\d{1,2})/){2}(XX|\d{2,4})\b

and it'll find any of your examples. Wot Doth This All Mean?

\b a Word break -- there must not be a word character +before+ this entire expression. This means it'll ignore "XXX/XX/XX".
( repeat group -- see below
( XX | \d{1,2} ) Either "XX" (exactly) or "a digit, 1 or 2". This means it'll ignore "XXX/XX/XX" (three exes), pick up "1/2/3" (one digit), ignore "123/123/123" (three digits)
/ A slash. Nothing special, except ...
) .. since this is the end of the repeat group ...
{2} ... we want twice the sequence "XX/" (or "digit/"), to match "XX/XX/" and every possible combo with digits as well.
( oh yet another group. That's because ...
XX .. this literal text ...
| ... OR ... (hold on, I'm gettin' there)
\d{2,4} .. two to four digits should be matched ..
) .. in this entire group.
\b Phew! A Word break to prevent it matching "12/34/5678*9*"

Miss Tiffany's picture

Thanks for following up with your answer. This sort of search is helpful for sure.

Theunis de Jong's picture

Ms. Tiff (like your new avatar, by the way!), if you have any GREP question at all, just post it into Adobe's own InDesign forum, or in David Blatner's InDesignSecrets forum.

I'm very partial to InDesign's GREP, always on the look-out for seemingly impossible things to figger out :-)

(Funny Commenting Explanation is an option, when I'm in the Mood.)

Miss Tiffany's picture

Yes, those forums are helpful too. :)

(by the way—and I know this will sound pompous—but I prefer Tiffany to Tiff.)

AndrewSipe's picture

Jong, ah! Thanks for the answer (sorry I didn't credit you as the answerer here). Wasn't aware you were a Typophile too.

butterick's picture

Type weenies should also investigate grep styles in inDesign.

Syndicate content Syndicate content