I have uploaded an updated version of the Search and change case script so it now supports a couple of extra features.

In addition to changing the case you can now apply a character style to the found text or make a local formatting change to "Small Caps" or "OpenType All Small Caps". Keep in mind that if you apply a character style, it will override the current character style of found items, if any.

Thanks to David Blatner for the idea.

The script is written in JavaScript and should work on both Windows and Mac in CS3 and CS4. You can download it from here.

Related to my guide regarding on using GREP styles to change words to small caps, I recently wrote this small script to let you really change case in a search.

The dialog box that opens when activating the script.

The dialog box that opens when activating the script

Activating the script lets you type in a search string, which also accepts GREP, and selecting which of the four cases you want the text transformed to, UPPERCASE, lowercase, Title Case or Sentence case. The script also lets you search a single story or a whole document.

The end result.

The end result

The script

The JavaScript can be downloaded here: search_change_case.jsx.

You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel" folder.
Note that depending on the length of your document, the script might take a while to run.

Changelog

1.5: Added options for applying a character style or local small caps formatting for the found text.

GREP searching was a highly needed and really convenient addition to InDesign, when it was added in CS3. Earlier, doing complicated search/replace, and cleaning up documents for extra spaces, tabs etc. was a longer procedure.

Still GREP's greatest force (in my opinion) inside InDesign was added in CS4, when GREP styles was introduced. Being able to change text appearance based on regexp is amazing.

As always, a little something for the wishlist:

Using groups in GREP styles

Being able to search for a longer string, but only applying the character style to the matched part of the results. If you want to highlight the word "bar", but only when "foo" is in front of it: "foo bar" >< "this bar". I would suggest being able to search for something like "foo (bar)" and only apply the character style to the group, "(bar)".

Character and paragraph style aware GREP searching

Prior to CS3, where GREP was introduced in InDesign, I normally would export the text story as InDesign Tagged Text and apply all my advanced searching on that document in any text editor. And I still do this, because what InDesigns GREP search lacks, are character and paragraph awareness.

In GREP search you are able to find/change formatting as well, which lets you target specific paragraph styles, but you are unable to search for "paragraph_style_1 followed by paragraph_style_2"-combinations, which can be really handy if you want to remove e.g. indentation from all paragraphs located after blank lines, subheadings etc.

Searching on pairs of paragraph styles isn't possible inside InDesign - to do the more advanced searches you still have to export the document as InDesign Tagged Text, and do the searches in your preffered text editor.

Searching in InDesign Tagged Text in TextMate

Also, you can use the regular regexp anchors, ^ and $, but these only applies to paragraphs. So if you search for a specific character style, you can't tell InDesign to look in the beginning/end of the found text, it only applies to the current paragraph. A set of extra anchors in InDesign please?

Searching from the beginning of a character style doesn't work. The ^ anchor still applies to the beginning of the paragraph.

GREP anchors and character styles

I usually keep all styling that differs from the paragraph styles I have created in character styles, making one for bold, italic, superscript ... text. But sometimes I wish I could apply more than one character style to the same text.

This wish probably originates from my background with HTML and CSS - being used to nest things within each others. When I look at a InDesign document, I see the same structure, character styles are inline objects inside the paragraph styles which are block objects.

Case 1: Superscript and italic text

In this case, I have a document with some text, some of the text are italic, and some of the text are superscript. I have created a character style for both, but suddenly I need to style a letter both italic and superscript. My only option: creating a new character style for this place alone.

Case 2: Coloured text

In this case my text is black, but different sentences are highlighted with a red text colour. Some of the text in one of the sentences are already italic - my only option: creating a new character style for this place alone.

Italicised text that is also marked red.

Italicised text that is also marked red

Some might call my crazy, but I never locally apply any formatting. I don't, because I don't want to risk anything loosing its formatting later in the process, if accidently overrides are cleared.

I thought of some different workarounds, like applying my red character style to the sentence, and then using Nested Style, Nested Line Styles, Drop Caps or GREP Style to apply the italic style to some text, and it actually worked in the different arrangements I tried.

Applying GREP style to text already marked with a character style.

Applying GREP style to text already marked with a character style

After testing a bit it turns out that you can do this as much as you like, applying unlimited amounts (only tested up to 10) of different character styles to the same text, using the 4 different types of nested styles available in InDesign. There is a hierarchy though, Nested Line Styles > Nested Styles > Drop Caps > GREP Style. Applying multiple GREP styles, they are prioritised after position in the GREP Style section, lowest with highest priority.

This is the only workaround I have been able to figure out, and honestly, it doesn't really solve anything, does it? It is a fun feature, and probably can be useful in some cases, but not specifically in the two I mentioned.

So please Adobe, make it possible to apply multiple character styles?

If you have a long document with different words set in CAPITALS, you probably would like to set those words with small caps instead.

Example of different words in small caps, applied automatically.

Small caps using GREP

As long as you are using an OpenType font, you can (often, depends on the font) change the text case using OpenType All Small Caps, which ignores the current letter case. Start by creating a character style that does this. The trick in this guide is how to apply it automatically.

This is where you choose OpenType All Small Caps.

OpenType All Small Caps

GREP styles

GREP style is a new feature in InDesign CS4, and works like Nested Styles, a way to apply a character style a part of a paragraph, based on the text content. GREP uses regular expressions (regexp) to find a text range, and if you learn/know your regexp, you will quickly start doing most your Nested Styles with GREP style instead.

This short guide is just to show you an easy to understand introduction to regexp and GREP styles. If you want to learn regexp, regular-expressions.info is a good resource.

This is where you write your regexp and choose what character style should be applied to the found text.

GREP Styles in paragraph options

By default, GREP is case sensitive, which you will use in this example. The regexp pattern here, [A-Z]{2,}, defines that you want to find letters from A to Z (uppercase), but there must be at least 2 after each others. If it had been [A-Z]{3,4}, there had to be at least 3 in a row, but max 4.

I will be sure to write more GREP style and GREP search guides on the blog, showing practical examples and usage of the features.