You are on page 1of 2

GREP and Metacharacters in the Find/Change dialog box of InDesign CS4

Description GREP Text Punctuation Space . . . . . . . . . . . . . . . . . . . . ~. . . . . . . ^. Any Lowercase Letter . . . . . . . . . . . . . . . . . . \l . . . . . . . . . Repeat GREP Text
Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\t . . . . . . . ^t Third Space . . . . . . . . . . . . . . . . . . . . . . . . . . . ~3 . . . . . . ^3 Any Uppercase Letter . . . . . . . . . . . . . . . . . . \u . . . . . . . . . Zero or One Time . . . . . . . . . . . . . . . . . . . . . . . ? . . . . . . . . .
Forced Line Break . . . . . . . . . . . . . . . . . . . . . \n . . . . . . . ^n Sixth Space . . . . . . . . . . . . . . . . . . . . . . . . . . ~% . . . . . . ^% Zero or More Times . . . . . . . . . . . . . . . . . . . . . * . . . . . . . . .
End of Paragraph . . . . . . . . . . . . . . . . . . . . . . \r . . . . . . . ^p Locations GREP Text One or More Times . . . . . . . . . . . . . . . . . . . . + . . . . . . . . .
Quotation Marks GREP Text Beginning of Word . . . . . . . . . . . . . . . . . . . . \< . . . . . . . . Zero or One Time (Shortest Match) . . . . . . . ?? . . . . . . . . .
Symbols GREP Text Any Double Quotation Marks . . . . . . . . . . . . . . . . . . . . . End of Word . . . . . . . . . . . . . . . . . . . . . . . . . . \> . . . . . . . . Zero or More Times (Shortest Match) . . . . . *? . . . . . . . . .
Bullet Character . . . . . . . . . . . . . . . . . . . . . ~8 . . . . . . ^8 Any Single Quotation Marks . . . . . . . . . . . . . . . . . . . . . Word Boundary . . . . . . . . . . . . . . . . . . . . . . . \b . . . . . . . . . One or More Times (Shortest Match) . . . . . +? . . . . . . . .
Carat Character ^ . . . . . . . . . . . . . . . . . . . . . \^ . . . . . . ^^ Straight Double Quotation Marks . . . . . . . ~ . . . . . . ^ Beginning of Paragraph . . . . . . . . . . . . . . . . ^ . . . . . . . . .
Backslash Character \ . . . . . . . . . . . . . . . . . . \\ . . . . . . . . \ Double Left Quotation Marks . . . . . . . . . . ~{ . . . . . . ^{ End of Paragraph . . . . . . . . . . . . . . . . . . . . . . . $ . . . . . . . . .
Copyright Symbol . . . . . . . . . . . . . . . . . . . ~2 . . . . . . ^2 Double Right Quotation Marks . . . . . . . . . ~} . . . . . . ^} Beginning of Story . . . . . . . . . . . . . . . . . . . . \A . . . . . . . . . InDesign CS4: More Undocumented GREP Code
Ellipsis . . . . . . . . . . . . . . . . . . . . . . . . . . . ~e . . . . . . ^e Straight Single Quotation Mark . . . . . . . . . ~ . . . . . . . . ^ End of Story . . . . . . . . . . . . . . . . . . . . . . . . . . \z . . . . . . . . . Letter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{letter}
Paragraph Symbol . . . . . . . . . . . . . . . . . . . ~7 . . . . . . ^7 Single Left Quotation Mark . . . . . . . . . . . . ~[ . . . . . . ^[ Lowercase letter . . . . . . . . . . . . . . . . . . . . . \p{lowercase_letter}
Registered Trademark Symbol . . . . . . . . . ~r . . . . . . ^r Single Right Quotation Mark . . . . . . . . . . . ~] . . . . . . ^] Match GREP Text Uppercase letter . . . . . . . . . . . . . . . . . . . . . \p{uppercase_letter}
Section Symbol . . . . . . . . . . . . . . . . . . . . . ~6 . . . . . . ^6 Marking Subexpression . . . . . . . . . . . . . . . . () . . . . . . . . . Titlecase letter . . . . . . . . . . . . . . . . . . . . . . . . \p{titlecase_letter}
Trademark Symbol . . . . . . . . . . . . . . . . . . ~d . . . . . . ^d Break Character GREP Text Non-Marking Subexpression . . . . . . . . . . . . (?:) . . . . . . . . Spacing modifier letter . . . . . . . . . . . . . . . . \p{modifier_letter}
Open Parenthesis ( . . . . . . . . . . . . . . . . . . . . \( . . . . . . . . ( Standard Carriage Return . . . . . . . . . . . . . . . ~b . . . . . . ^b Character Set . . . . . . . . . . . . . . . . . . . . . . . . . [] . . . . . . . . . Non-case non-modifier letters . . . . . . . . . . . . \p{letter_other}
Closed Parenthesis ) . . . . . . . . . . . . . . . . . . . \) . . . . . . . . ) Column Break . . . . . . . . . . . . . . . . . . . . . . . ~M . . . . . . ^M Or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | . . . . . . . . . Marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{mark}
Open Brace Character { . . . . . . . . . . . . . . . . . \{ . . . . . . . . { Frame Break . . . . . . . . . . . . . . . . . . . . . . . . . . ~R . . . . . . ^R Positive Lookbehind . . . . . . . . . . . . . . . . . (?<=) . . . . . . . Diacritical and tone marks . . . . . . . . . . \p{non_spacing_mark}
Closed Brace Character } . . . . . . . . . . . . . . . . \} . . . . . . . . } Page Break . . . . . . . . . . . . . . . . . . . . . . . . . . . ~P . . . . . . ^P Negative Lookbehind . . . . . . . . . . . . . . . . . (?<!) . . . . . . . Vowels SE Asian languages . . . \p{spacing_combining_mark}
Open Bracket Character [ . . . . . . . . . . . . . . . \[ . . . . . . . . [ Odd Page Break . . . . . . . . . . . . . . . . . . . . . . . ~L . . . . . . ^L Positive Lookahead . . . . . . . . . . . . . . . . . . . (?=) . . . . . . . . Circles, squares, keycaps . . . . . . . . . . . . . . . \p{enclosing_mark}
Closed Bracket Character ] . . . . . . . . . . . . . . \] . . . . . . . . ] Even Page Break . . . . . . . . . . . . . . . . . . . . . . ~E . . . . . . ^E Negative Lookahead . . . . . . . . . . . . . . . . . . . (?!) . . . . . . . . Spaces, returns, 2028, 2029 . . . . . . . . . . . . . . . . . . \p{separator}
Discretionary Line Break . . . . . . . . . . . . . . . ~k . . . . . . ^k All spaces except tab & return . . . . . . . . . .\p{space_separator}
Markers GREP Text Modifiers GREP Text Line separator character 2028 . . . . . . . . . . . \p{line_separator}
Any Page Number . . . . . . . . . . . . . . . . . . . . . ~# . . . . . . ^# Variable GREP Text Case-Insensitive On . . . . . . . . . . . . . . . . . . . . (?i) . . . . . . . . Paragraph separator 2029 . . . . . . . . . \p{paragraph_separator}
Current Page Number . . . . . . . . . . . . . . . . . . ~N . . . . . . ^N Any Variable . . . . . . . . . . . . . . . . . . . . . . . . . . ~v . . . . . . ^v Case-Insensitive Off . . . . . . . . . . . . . . . . . . (?-i) . . . . . . . . Math and Wingdings . . . . . . . . . . . . . . . . . . . . . . . . . . \p{symbol}
Next Page Number . . . . . . . . . . . . . . . . . . . . ~X . . . . . . ^X Running Header (Paragraph Style) . . . . . . . ~Y . . . . . . ^Y Multiline On . . . . . . . . . . . . . . . . . . . . . . . . . (?m) . . . . . . . Math symbols . . . . . . . . . . . . . . . . . . . . . . . . . .\p{math_symbol}
Previous Page Number . . . . . . . . . . . . . . . . . ~V . . . . . . ^V Running Header (Character Style) . . . . . . . ~Z . . . . . . ^Z Multiline Off . . . . . . . . . . . . . . . . . . . . . . . . . (?-m) . . . . . . . Currency symbols . . . . . . . . . . . . . . . . . . . \p{currency_symbol}
Section Marker . . . . . . . . . . . . . . . . . . . . . . . ~x . . . . . . ^x Custom Text . . . . . . . . . . . . . . . . . . . . . . . . . . ~u . . . . . . ^u Single-Line On . . . . . . . . . . . . . . . . . . . . . . . . (?s) . . . . . . . . Modifier symbols . . . . . . . . . . . . . . . . . . . . \p{modifier_symbol}
Anchored Object Marker . . . . . . . . . . . . . . . . ~a . . . . . . ^a Last Page Number . . . . . . . . . . . . . . . . . . . . . ~T . . . . . . ^T Single-Line Off . . . . . . . . . . . . . . . . . . . . . . . (?-s) . . . . . . . . Wingdings, dingbats . . . . . . . . . . . . . . . . . . . \p{other_symbol}
Footnote Reference Marker . . . . . . . . . . . . . ~F . . . . . . ^F Chapter Number . . . . . . . . . . . . . . . . . . . . . . ~H . . . . . . ^H Ignore Whitespace On . . . . . . . . . . . . . . . . .(?w) . . . . . . . . Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{number}
Index Reference Marker . . . . . . . . . . . . . . . . ~I . . . . . . ^I Creation Date . . . . . . . . . . . . . . . . . . . . . . . . . ~O . . . . . . ^O Ignore Whitespace Off . . . . . . . . . . . . . . . . (?-w) . . . . . . . Digits 0 to 9 . . . . . . . . . . . . . . . . . . . . \p{decimal_digit_number}
Modification Date . . . . . . . . . . . . . . . . . . . . . ~o . . . . . . ^o Roman numerals . . . . . . . . . . . . . . . . . . . . . . . \p{letter_number}
Hyphens and Dashes GREP Text Output Date . . . . . . . . . . . . . . . . . . . . . . . . . . ~D . . . . . . ^D Change to Other GREP Text Other numbers . . . . . . . . . . . . . . . . . . . . . . . . . \p{other_number}
Em Dash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~_ . . . . . . ^_ File Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~1 . . . . . . ^1 Clipboard Contents, Formatted . . . . . . . . . . ~c . . . . . . . . Punctuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{punctuation}
En Dash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~= . . . . . . ^= Clipboard Contents, Unformatted . . . . . . . . ~C . . . . . . . . Hyphens and dashes . . . . . . . . . . . . . . . . \p{dash_punctuation}
Discretionary Hyphen . . . . . . . . . . . . . . . . . . ~- . . . . . . ^- Other GREP Text Opening parentheses, braces . . . . . . . . \p{open_punctuation}
Nonbreaking Hyphen . . . . . . . . . . . . . . . . . ~~ . . . . . . ^~ Right Indent Tab . . . . . . . . . . . . . . . . . . . . . . ~y . . . . . . ^y Change to Found GREP Text Closing parentheses, brackets . . . . . . . \p{close_punctuation}
Indent To Here . . . . . . . . . . . . . . . . . . . . . . . . ~i . . . . . . ^i Found Text . . . . . . . . . . . . . . . . . . . . . . . . . . . $0 . . . . . . . . Opening quotes . . . . . . . . . . . . . . . . . . . \p{initial_punctuation}
White Space GREP Text End Nested Style Here . . . . . . . . . . . . . . . . . ~h . . . . . . ^h Found 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $1 . . . . . . . . Closing quotes . . . . . . . . . . . . . . . . . . . . . . \p{final_punctuation}
Em Space . . . . . . . . . . . . . . . . . . . . . . . . . . . ~m . . . . . . ^m Non-Joiner . . . . . . . . . . . . . . . . . . . . . . . . . . . ~j . . . . . . ^j Found 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $2 . . . . . . . . Underscore, 203F, 2040, 2054 . . . \p{connector_punctuation}
En Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~> . . . . . . ^> Found 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $3 . . . . . . . . Other punctuation . . . . . . . . . . . . . . . . . \p{other_punctuation}
Flush Space . . . . . . . . . . . . . . . . . . . . . . . . . . ~f . . . . . . ^f Wildcards GREP Text Found 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $4 . . . . . . . . Other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{other}
Hair Space . . . . . . . . . . . . . . . . . . . . . . . . . . . ~| . . . . . . ^| Any Digit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \d . . . . . . . ^d Found 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $5 . . . . . . . . Control characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{control}
Nonbreaking Space . . . . . . . . . . . . . . . . . . . . ~S . . . . . . ^S Any Letter . . . . . . . . . . . . . . . . . . . . . . . . . . . [\l\u] . . . . . ^$ Found 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $6 . . . . . . . . Formatting character markers . . . . . . . . . . . . . . . . . . \p{format}
Nonbreaking Space (Fixed Width) . . . . . . . . ~s . . . . . . ^s Any Character . . . . . . . . . . . . . . . . . . . . . . period . . . . . ^? Found 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $7 . . . . . . . . E000F8FF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \p{private_use}
Thin Space . . . . . . . . . . . . . . . . . . . . . . . . . . ~< . . . . . . ^< Any White Space . . . . . . . . . . . . . . . . . . . . . . \s . . . . . . . ^w Found 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $8 . . . . . . . . Unassigned Unicode range . . . . . . . . . . . . . . . . . \p{unassigned}
Figure Space . . . . . . . . . . . . . . . . . . . . . . . . . . ~/ . . . . . . ^/ Any Word Character . . . . . . . . . . . . . . . . . . . \w . . . . . . . . Found 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $9 . . . . . . . .

mikewitherell@jetsetcom.net | www.jetsetcom.net | urszulawitherell@jetsetcom.net


GREP and InDesign CS4 Some useful search situation examples to explore
1.Find ALL CAPS paragraphs 6.Find and delete soft return line breaks 12.Search for phone numbers to regularize 16.TitleCase applied except for small words
Find: \u\u(\.\?\r?)$ Find: \s?\n Find: \d?[-. ]? Find: :\s\l|[-\s]\l(?!(f|he|nd?|o|y|rom|or|ut)?\b)
Change with formatting: paragraph style Change: with single spacebar space \(?(\d{3})\)?[-. ]?(\d{3})[-. ]?(\d{4}) Change: formatting to All Caps styling
Note: When your untagged text has occasional paragraphs typed Note: Soft returns replaced by spacebar space Change: $1.$2.$3 Note: Search the selection. Leave the Change what field blank.
in all caps, this script finds two uppercase letters followed by a Or Change: $1-$2-$3 or Change: ($1) $2-$3 This wont work on all uppercase text! This also converts to
period and a hard return. This is enough to find such paragraphs uppercase any word that follows a colon or a hyphen.
and tag them. Step 2, run ChangeCaseofSelectedStyle.jsx, a 7.Find quoted words and change to italic Note: This finds a sequence of 3, 3, and 4 digits. The ? symbol
script by Dave Saunders of PDSAssoc.com. This converts case. indicates that the element can exist zero or one time in the
Find: (~{)(\u*\l*\s*.*\w*\d*)(~}) 17.Undocumented negation in Wildcards
string, so the code [-. ]? means that a hyphen, dot, or space may
Change: $2 and italic character style formatting or may not exist between the digits. Replace can use periods, Not documented in the Wildcards flyout is that the
2.Find ALL CAPS words parentheses, or hyphens, as you wish.
Note: This finds the quotes but leaves them out since it only uppercase version of the wildcards negates them.
Find: \<[A-Z]{2,}\> changes to found group 2; not 1 and 3.
13.Search for dates to format Note: Thus, \D finds everything that is not a digit; \U finds
Change: with formatting: OpenType All Caps everything that is not an uppercase letter, and \L finds
Note: The minimal length {2,} is to prevent it picking up all 8.Find all email addresses Find: \d\d?-\d\d?-(\d\d)?\d\d everything that is not a lowercase letter, etc.
single capitals (remove if you want those as well). Ideally, you Change: with formatting from the character styles
Find: [\l\u\d_%-]+@[\l\u\d_%-]+
search full caps with this regular expression and replace them
panel 18.Find underlining and replace with italics
with OpenType All Caps. Any other way will need handwork or a Change: with formatting
script. For international text, you should search for \<\u{2,}\> Notes: This sequence finds dates formatted like 09-04-2008 as Find Formatting: Underline
(the \u uppercase wildcard also finds capital "") Note: The _, %, and hyphen were added because those
well as 9-4-08, and allows you to apply a character style.
characters are not included in the wildcard codes. The square Change Formatting: Italic character style
brackets group the codes together. The + indicates that these
3.Find capital letters like acronyms characters can appear any number of times, or not at all. The @ This uses Text; not GREP, and is good because character styles
14.Replace multiple terms with one term control better than direct formatting. Note: Have pre-built
sign is outside the group to appear only once. The group is then
Find: \u\u+ or Find: >\<\u\u+\> repeated for the rest of the address. Find: illustration | graph | map | chart character styles for bold, italic, and bold italic. Also, have
superscript, smallcaps, and other character styles defining
Change: with formatting; such as SmallCaps Change: figure swatch colors pre-built for use in Find/Change as well as nested
Note: This finds 2 or more uppercase letters. The \< and \> are 9.Capitalize first letter of word after bullet Note: The list of alternative words must be separated by the
styles.
word delimiters, so it won't alter anything else than caps words. Find: (.)(\t)(\l) vertical bar, and each alternative is rplaced with the replace
If the Replace field is empty and it has formatting, it applies the term. GREP is case sensitive by default; so to replace case- 19.Interpret GREP into English
formatting to the found text. Only if there is also no formatting, Change: $1$2$3 insensitively, add (?i) before the expression.
it replaces with nothing. RegexBuddy (http://www.regexbuddy.com/)
Note: In the Replace formatting set text to uppercase
15.Find or remove trailing characters after Notes: To see the translation, click the Create tab after entering a
4.Find and delete email quote angle regular expression. You will see that the program has listed your
10.Search for words with brackets numbers, as in 1st, 2nd, 3rd, 4th expression as a sequence of icons/explanations. Windows-only.
brackets
Find: \[\w{4,20}\] Find:
Find: >+ +
Change: with formatting (?<=\d)+st|(?<=\d)+th|(?<=\d)+nd|(?<=\d)+rd
Change: leave blank
Note: This finds with brackets (could be parentheses) Change: leave blank, to strip out; or apply Michael Witherell | mikewitherell@jetsetcom.net
Note: This deletes all > and any spaces with them formatting of superscript character style Adobe Certified Experts
11.Search for words within brackets Note: In this example, we are looking for the two-letter trailing Urszula Witherell | urszulawitherell@jetsetcom.net
5.Thin spaces around em dashes characters to strip off the number. The pipe character is an OR Join us for training in:
Find: (?<=\[)\w{4,20}(?=\]) statement. So, the search repeats itself four times, saying that
Find: (?<!~<)(~_)(?!~<) InDesign | Illustrator | Photoshop | Acrobat | InCopy
if the characters occur where there is a digit preceding it, then
Change: with formatting
Change: ~<$0~< the characters will be removed. If you surround the text with Book us online at: www.jetsetcom.net
Note: This finds within but not including brackets parentheses, you could superscript the found text instead of
This finds em dashes without thin spaces and puts them in. stripping it out.

mikewitherell@jetsetcom.net | www.jetsetcom.net | urszulawitherell@jetsetcom.net

You might also like