Skip to main content
Participating Frequently
September 3, 2025
Answered

Another grep request, much appreciated

  • September 3, 2025
  • 2 replies
  • 417 views

Hello all.

I can find grep commands that do some of these things, but I need one that does all of them. For some wild reason, after spending hours online, I cannot find the solution. I appreciate your help. No, nested styles do not help here. I need a command in my paragraph style that does this:

- applies a character style up to AND INCLUDING a colon, ONLY if there's a colon in the paragraph.

- Ideally this goes up to just the first colon. If that's not possible, I need to set a word limit (let's say 10 words for example) on how far the search goes into the paragraph.

Thank you.

Correct answer FRIdNGE

Words Limit = 10! So:

^(\H+\h){0,9}?\H+:

 

Words Limit = 4! So:

^(\H+\h){0,3}?\H+:

 

(^/)

2 replies

Dave Creamer of IDEAS
Community Expert
Community Expert
September 3, 2025

Couldn't nested styles do this too?

 

David Creamer: Community Expert (ACI and ACE 1995-2023)
Peter Spier
Community Expert
Community Expert
September 3, 2025
quote

Couldn't nested styles do this too?

 


By @Dave Creamer of IDEAS

I think the requirement for no match if there's no colon rules out a nested style as it would end up matching the entire paragraph.

Beemo8bitAuthor
Participating Frequently
September 3, 2025

Correct, I tried this already. If Adobe could add a nested style option for 'after' as well as 'before' or 'through', that would be a game changer! A feature I see that requested many years ago already....

m1b
Community Expert
Community Expert
September 3, 2025

Hi @Beemo8bit, add a Grep style with this pattern:

^[^:]+:

 

It means: 

^        match start of text

[^:]+  match one or more characters that aren't colon

:         match one colon

FRIdNGE
September 3, 2025

^.+?:

 

(^/) The Jedi