(GREP) formatting numbers/letters in succession

Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Hi InDesign community,

I have a catalog with product numbers and there are a lot of numbers/letters that need to be formatted in color when they appear behind each other.

However they should not be formatted when there is only one instance and afterwards there's a line break.

 

Right now I am using this code, but it does not catch the letters and the one-instance numbers are also formatted which they should not.

(?<=-|\.|\s)\d{2}(?!\d)

 

This is how my file looks like with the above code:

(pink line just added for emphasis that this is the wrong appearance)

 

Bildschirmfoto 2022-06-29 um 16.34.56.png

 

And this is how it SHOULD look like:

 

Bildschirmfoto 2022-06-29 um 16.34.09.png

 

I imagine I need to find some way to check if there are multiple instances in one line. There is always a break after each line.  But I am unsure on how to do it. Can you help me?

TOPICS
Scripting

Views

115

Likes

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
Advisor ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

This could probably not be done with one simple regex... Maybe multiple one like here...


Screen.png

Likes

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Hi Jean-Claude, 

that's amazing, thank you!

I looked at your code in detail and learned a lot about GREP just by informing myself about all the different expressions that you used.

 

The code works well, there is just one minor bug I see.

mira_00_0-1656594383550.png

 

In the first line, the code also catches the "VA" from "VAR", which should be left alone.

I wonder how to fix that, I suppose we need to tell the GREP to stay away from longer words?

Likes

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
Advisor ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Or you can target them and style them black again.

Does the first 00 in VAR-0000-00, VAR-0000-00 need to be blue?

 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

quote

Does the first 00 in VAR-0000-00, VAR-0000-00 need to be blue?

 


By @Jean-Claude Tremblay

 

Hi Jean-Claude,

no, it should not be blue. It's a bit complicated, unfortunately, but in this case there are two separate product numbers and thus tbey should not be fomatted.

 

The numbers in the lines below all have different options and this is why these options need to be highlighted with a color.

Likes

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
Advisor ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Screen 1.pngMaybe this... 

 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

LATEST

Hi @mira_00 

please read your older thread again carefully. With all the questions about concrete rules and exceptions and the requests for example texts. Otherwise, this thread will also fizzle out and quietly end without any real solution.

See --> (GREP) formatting product numbers

Likes

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