GREP of the Month: Case Sensitivity
Sometimes case matters, and sometimes it does not—even in a single Find/Change operation.

This article appears in Issue 75 of InDesign Magazine.
By default, a regular Find Text operation in InDesign is case insensitive (that is, it ignores all capitalization). To make it case sensitive, you can click the little [Aa] button below the Search menu.
In contrast, the GREP Find What field in the same dialog box behaves the exact opposite: it is always case sensitive—but there is no [Aa] button to allow you to turn case sensitivity off! So what can you do when case matters? A clue is in the drop-down menu, under “Modifiers:” there you can find both “Case-insensitive On” and “Case-insensitive Off.”
This inserts the code (?i)
for insensitive on (i.e. “case sensitive off”, the reverse of what you might think!) and (?-i)
to switch case insensitive off (i.e. “case sensitive on”).
To search for “Text” case insensitive, you can use (?i)Text
(or (?i)text
, or any other combination of uppercase and lowercase letters, e.g. (?i)tExT
.
But since you’re using a command, you can switch the modes inside a single Find at will! You can search for both “the AMA” and “The AMA” at once using this: (?i)the (?-i)AMA
—and it will not match the start of “the amazing cat”. That is not something you can do with the regular Find Text!
Another neat trick is that you can use parentheses to group some text inside the command itself, after a colon: (?i:the) AMA
does the same as the example above. If there is any text inside the command switch, the switch will be ‘activated’ only for that text inside, and everything on the outside will use the setting that was active before this last command. You can even invert the settings:
(?i)the (?-i:AMA)
globally switches case sensitivity off, finds “the”, then switches case sensitivity on again to find only the literal all-caps “AMA”.
Very important note: this GREP code does not work in the Change To field. Any text in the Change To field will always be inserted exactly as you entered it there. Unfortunately, the GREP engine used in InDesign simply cannot change case.
Commenting is easier and faster when you're logged in!
Recommended for you

Illustrator Downloadable: Tropical Shadow Overlay Kit
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

Illustrator Downloadable: Summer Citrus Pattern Set
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

InDesign Downloadable: Tables SuperGuide
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...