• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Overlapping Grep Queries

Community Beginner ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

Hi, everyone!

I'm using GREP to apply some character styles within my paragraph styles, but I have a conflict.

- Whenever "Emergency Stop button" comes up, I want to apply "btn red" character style to that text. 
- Whenver "Stop button" is found, I want to apply "btn blue" character style.

As you can see, this is a conflict. Is there a way to tell the "Stop button" GREP to apply only if the word before is not Emergency?

I took a quick look at the existing GREP posts, and didn't see this asked, but my GREP knowledge is almost nonexistent. My apologies if it was already answered and I missed it!

TOPICS
Scripting

Views

165

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Oct 07, 2022 Oct 07, 2022

This should work

Capture d’écran 2022-10-07 à 18.53.13.jpg

 

(?<!Emergency )Stop button

 

I inserted a negative Lookbehind before “Stop button”. It means that blue style will be applied only if there is no Emergency (followed by a space)

Votes

Translate

Translate
Community Expert , Oct 07, 2022 Oct 07, 2022

You change the order or the GREP queries. In the first image “Emergency Stop button” is coloured red, then “Stop Button” is coloured blue. In the second image “Stop Button” is coloured blue then “Emergency Stop button” is coloured red, which overrides the unwanted blue colouring.

Screenshot 2022-10-07 at 10.22.46 AM.pngScreenshot 2022-10-07 at 10.23.12 AM.png

Votes

Translate

Translate
Community Expert ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

This should work

Capture d’écran 2022-10-07 à 18.53.13.jpg

 

(?<!Emergency )Stop button

 

I inserted a negative Lookbehind before “Stop button”. It means that blue style will be applied only if there is no Emergency (followed by a space)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

Thank you so much! Works perfectly. And thank you for the explaination. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

You change the order or the GREP queries. In the first image “Emergency Stop button” is coloured red, then “Stop Button” is coloured blue. In the second image “Stop Button” is coloured blue then “Emergency Stop button” is coloured red, which overrides the unwanted blue colouring.

Screenshot 2022-10-07 at 10.22.46 AM.pngScreenshot 2022-10-07 at 10.23.12 AM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

LATEST

I hadn't realized. Ok, that's also good to know. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines