Skip to main content
Known Participant
April 10, 2019
Answered

Is there a Grep that will style everything after a certain word?

  • April 10, 2019
  • 5 replies
  • 8052 views

Hi. I need to make everything after and including the word "NOW" bold and a certain color. Is this possible. Thank you for any help!

This topic has been closed for replies.
Correct answer FRIdNGE

Hi,

I've always preferred the precision! …

(\bNOW\b)(.(?!\1))+$

Best,

Michel, for FRIdNGE

5 replies

jane-e
Community Expert
Community Expert
April 10, 2019

Hi epheweAll

Just because no one has said it yet:

Whether you go with GREP or nested styles, you will need to create paragraph and character styles.

  • For GREP, you go to the GREP part of the paragraph style and put in the code, then assign the character style.
  • For nested styles, you say “use this character style until it meets this condition”, then use the paragraph style.

This is over-simplified, and you may know it already, but others may also come across this with a Search. We can explain in greater detail if necessary.

Jane

Stephen Marsh
Community Expert
Community Expert
April 10, 2019

Another approach, which is just a variation:

.+\KNOW.+

FRIdNGE
FRIdNGECorrect answer
Inspiring
April 10, 2019

Hi,

I've always preferred the precision! …

(\bNOW\b)(.(?!\1))+$

Best,

Michel, for FRIdNGE

epheweAllAuthor
Known Participant
April 10, 2019

Thanks Michel! Works great. Cheers

Community Expert
April 10, 2019

Hi epheweAll ,

that would be a positive look behind for the word:

(?<=\bNOW).+

If you don't like to include the white space after the word:

(?<=\bNOW\s).+

Depending how often the word NOW is used in the paragraph we need a more precise approach.

Regards,
Uwe

vladan saveljic
Inspiring
April 10, 2019

Hi Uwe,

epheweAll wants to include the word NOW

Community Expert
April 10, 2019

Ah yes. Did not have my morning coffee…

Thanks, Vladan!

Willi Adelberger
Community Expert
Community Expert
April 10, 2019

A nested style would have a better performance.

Barb Binder
Community Expert
Community Expert
April 10, 2019

This is an interesting comment (and one I have never considered):

A nested style would have a better performance.

So here is my question for all of you GREP gurus on this thread: if you can accomplish the same task with either  nested styles (in the OP's example, three nested styles) or one nested GREP style—is there an advantage to going with nested vs GREP? Do nested styles have measurably better performance, apples to apples?

~Barb

~Barb at Rocky Mountain Training
MW Design
Inspiring
April 10, 2019

Barb,

I think the performance of GREP styles versus Nested styles has to be similar at the simple level. ID still needs to evaluate the paragraph they are part of for changes in conditions, words, phrases, etc.

Here's a short version of why I choose one versus the other.

If it can be done with a nested style, I'll do it that way. If for no other reason it is "dumb" logic. I only really use nested styles for lead-ins, simple changes to the appearance of a repeated word or phrase, etc.

If I need to find a pattern(s), then I will use GREP styles. Especially if there are more than single logic statements needed.

Else I'll use f/c (where GREP may/will be involved) or cobble together a script if I have to.

Mike

vladan saveljic
Inspiring
April 10, 2019

if you want to find everything, try this

\bNOW.+

but let us know if you don't want to find just everything after the word NOW

epheweAllAuthor
Known Participant
April 10, 2019

Thanks so much Vladan!