Reply To: Requesting help with GREP Look Behind …

Home Page / Forums / General InDesign Topics (CLOSED) / Requesting help with GREP Look Behind … / Reply To: Requesting help with GREP Look Behind …

#65789

Then you have *two* problems …

First off: GREP Styles cannot help you with this, in any way. They CANNOT apply a paragraph style, and they CANNOT apply or check anything outside of their own paragraph. They live in a small, one-paragraph-sized world of their own.

Second: alas, your suggested GREP wouldn’t work either! The basic idea would look like this:

CHAPTER \u+\r.

(the last full stop is important!) Other than my example above, this now also contains ‘all uppercase, any number of them’, so it can match ‘ONE’, ‘TWO’, and ‘THREE’; and if you try it, you will see it grabs a chapter plus number, a next hard return, and a single character of the next paragraph. Should you apply a paragraph style now, then it gets applied to both paragraphs.

But you only want to grab the second, so that’s why you suggested a lookbehind (that’s the part I initially missed). Moving the part before the to-be-adjusted paragraph into a lookbehind, you would get this:

(?<=CHAPTER \u+\r).

and this *ought* to find a single character, with ‘CHAPTER’ (etc) on the line above. But it does not work! The reason is your capitalized numerals have different lengths — ‘ONE’ is 3 characters, ‘TWO’ also 3, and ‘THREE’ has 5 — and a lookbehind cannot test for a variable length of characters. This is just too complicated for a single GREP.

A possible (and tricky) solution is to do multiple tests, each one with a fixed length:

((?<=CHAPTER \u\u\u\r)|(?<=CHAPTER \u\u\u\u)|(?<=CHAPTER \u\u\u\u\u)).

will work for ONE up to TEN (for ELEVEN and/or TWELVE you need to add a 6-uppercase check, after that 8, and so on and so forth).

This article was last modified on October 15, 2013

Comments (0)

Loading comments...