More on my obsession with GREP

In a blog post a few days back, I was confounded by the problem of converting ALL CAPS into lower case letters. Using a Javascript that I licensed from a Danish programmer, I was able to make the case change, but the GREP search was also converting articles like I and A into lower case, and that was creating a new (but easily soluble) problem.

One of my former students, Jeff Bauer, sent me a fix that he found on a programmer’s web site. It solves a related problem using the same Javascript: not changing Roman Numerals into lower-case letters. Curiously, that solution also solves the articles problem I was having.

Thank you Jeff for submitting the solution to my problem!

Let’s take a look at how it’s done. I had wrestled with this problem, and had failed to find a solution because I do not know how to use “negative look-aheads” in GREP. I tried, believe me, but I failed to solve the problem.

The solution Jeff sent is complex but elegant: \b(?![LXIVCDM]+\b)([A-Z]{2,})\b

Huh? This uses both a negative look-ahead, and a little-documented GREP feature that says “this has to be at least two characters in length. It’s the part in series braces {}.

Here is a diagram of how it works:

My test document is a page of InDesign-generated pseudo-Latin into which I inserted a handful of all-caps examples, as well as a few cap-I and cap-A situations. I also threw-in Roman numerals to test the advertised function of the string.

Above: the text before I ran the search for all-caps.

The search string works fine, except for one exception where it fails with a string of all-caps letters preceded by a hyphen.

Above is the same text after I ran the script with the new GREP string. Notice the single word that is still capitalized, a compound word.

I guess that’s my next challenge.

_____

I’m writing a new book about printing processes and prepress. Click on the link below to give me your e-mail address, and I will let you know when the book is published (target date is March, 2012).

About Brian Lawler

Brian Lawler is an Emeritus Professor of Graphic Communication at California Polytechnic State University, San Luis Obispo and was a Guest Professor at Hochschule München from September, 2021 to September, 2022. He writes about graphic arts processes and technologies for various industry publications, and on his blog, The Blognosticator.
This entry was posted in Imposition and Pagination. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.