Reply To: Grep for negative pattern match?

Home Page / Forums / General InDesign Topics (CLOSED) / Grep for negative pattern match? / Reply To: Grep for negative pattern match?

#53550

Sure it's possible! It's a matter of grouping:

a((?!cold).)+?night

works, because the outer parentheses group is what gets repeated, and inside the parentheses every single character is checked to not have 'cold' in front of it.

For added fun, you can add word boundaries before and after 'cold', so it will not reject 'a scolding hot night' ;-)

a((?!cold).)+?night

 

(Ed.: Added '?' after the pluses so it will match shortest possible strings only — usually, that's what you'd want.)

This article was last modified on July 21, 2010

Comments (0)

Loading comments...