InDesign GREP rules can get a bit mind-bending. Suppose you want a paragraph style with a GREP style rule that applies a character style to everything except text after a certain character. Something that doesn't apply to characters after a certain character, but applies to everything else?
For example, imagine a long list of article titles. Some are short titles, some are two parts with a short title then a colon then an elaboration. You want the whole of the short title ones to be emphasised, and everything up to and including the colon to be emphasised in the long ones:
- Adders of Angola
- Brilliant Badgers: the brawniest beasts of Britain
- Caravanning Crazes of Coastal Canadian carp
- Danger: the dastardly ducks of Denmark
I've tried a bunch of rules but none seem to work for this. I thought it might be possible using a 'negative lookbehind', like
(?<!:.*). or something, but nothing like that seems to work: it looks as if 'lookbehinds' and 'lookaheads' can only apply to the character immediately before the character you're looking for.
Any GREP experts got any ideas?
Here's one thing I figured out after a lot of browsing and trial and error, which I think logically should work, but doesn't work, for reasons I can't figure out:
In theory, that should mean "Grab everything from the paragraph start until the end of the first run of characters that aren't ':', or, if there's a run of characters that aren't ':' from paragraph start until a ':', grab that including the ':'".
In practice, it just applies to everything. Can't figure out why.