Reply To: Why oh why is this GREP query seemingly impossible?

Home Page / Forums / General InDesign Topics (CLOSED) / Why oh why is this GREP query seemingly impossible? / Reply To: Why oh why is this GREP query seemingly impossible?

#59380

According to the above, you're looking for a (forced line break followed by some other stuff) immediately after an open brace. Which wouldn't match the example you give, but would probably work given a stylesheet with the right sort of formatting, for example:

p {

color: #000;

}

em {

color: #555;

a {

color: #f00;

}

So I'm going to assume that's what you meant to do. In my experiments, using the above example rather than the one you gave, I found that both 'shortest' and 'longest' searches matched the same text.

However, it might not be the best idea to specify the forced line break at the start – you might not always have the contents of the braces on a separate line. Perhaps it would be better to find 'some stuff that might include one or more line breaks'? If so, you'd be better off with something like:

(?>={)([rn]|.)+(?={)

Now this one does work with a 'shortest' match:

(?>={)([rn]|.)+(?={)

But of course, what you're actually wanting to pick up is unmatched braces. So what you need to do is specify that you want to find stuff between an opening and an opening brace that doesn't contain a closing brace. How about something like this?

(?<={)([rn]|[^}])+?(?={)

Let us know how you get on!

This article was last modified on April 22, 2011

Comments (0)

Loading comments...