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

How to add colours to the list of text alternatively (GREP)?

Explorer ,
Mar 06, 2025 Mar 06, 2025

Hi,

I would like to add colours to alternative numbers so that it is easy to read like this:

12 (13, 14, 15, 16, 17, 18)

 

Brackets needs to be where it is placed.

Does anyone one know how I can use GREP so that it is applied to the document? I find GREP so hard to understand!

 

Many thanks for your help.

TOPICS
How to
1.7K
Translate
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 1 Correct answer

Guide , Mar 07, 2025 Mar 07, 2025

Just For Comment:

 

Supposing someone only wants to colorize numbers between parenthesis! … [first, third, fifth, seventh, …]

In this case, alas, Eugene's Grep code gives us an error on each text line!

 

Capture d’écran 2025-03-07 à 16.16.58.png

 

Personally, I've never thought trying to write an "magical" unique Grep code is the fastest and best way to play!!

 

But write a simple Grep code we can duplicate is a way I often use, faster and simpler to play, with more control too!  😉

 

Here:

 

Grep Style 1:  \((\d+,\h){0}\K\d+(?=.*\))

Grep Style 2:  

...
Translate
LEGEND ,
Mar 06, 2025 Mar 06, 2025

@Kyoko5CD0

 

Do you want to run global GREP Find&Change - or use GREP Styles?

 

Translate
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
Explorer ,
Mar 06, 2025 Mar 06, 2025

Hi!

Please could you teach me how to do both?

Global means to add GREP in the character style right? Yes I would like to know that as well as Find&Change. Are the code the same?

Thank you so much!

 

Translate
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 ,
Mar 06, 2025 Mar 06, 2025

copy this GREP

(?!\()\d+(\d+[\(\),\[\] ]*)\K\d+

 

Create a character style for the Red Text

 

In the Paragraph Styles go to the GREP Style section

 

Insert the code

and select your Red character style.  

 

Screenshot 2025-03-07 at 07.14.30.png

Translate
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
Guide ,
Mar 07, 2025 Mar 07, 2025

Just For Comment:

 

Supposing someone only wants to colorize numbers between parenthesis! … [first, third, fifth, seventh, …]

In this case, alas, Eugene's Grep code gives us an error on each text line!

 

Capture d’écran 2025-03-07 à 16.16.58.png

 

Personally, I've never thought trying to write an "magical" unique Grep code is the fastest and best way to play!!

 

But write a simple Grep code we can duplicate is a way I often use, faster and simpler to play, with more control too!  😉

 

Here:

 

Grep Style 1:  \((\d+,\h){0}\K\d+(?=.*\))

Grep Style 2:  \((\d+,\h){2}\K\d+(?=.*\))

Grep Style 3:  \((\d+,\h){4}\K\d+(?=.*\))

Grep Style 4:  \((\d+,\h){6}\K\d+(?=.*\))

Grep Style 5:  \((\d+,\h){8}\K\d+(?=.*\))

 

The numbers in pink gives us the number place between parenthesis.

To get the second, fourth, sixth, eighth, tenth number, just change:

0 => 1,  2 => 3,  4 => 5,  6 => 7,  8 => 9.

 

(^/)  The Jedi

Translate
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 ,
Mar 07, 2025 Mar 07, 2025

Great, thanks for sharing! 

 

Actually not sure why the 100 is not being picked up by my GREP, it works on the Mac, but not on Windows, very strange behaviour, as it does work... maybe too complex.

 

Beacause \d+ should pick up all the digits but it doesn't on Windows... 

 

Anyway - a way to do it too. 

Must remember this trick, of course I didn't test multiple GREPs. 

 

It was challenging to come up with 1 GREP - which fits the scenario.

But not additional scenarios that were not present and didn't test - which is fine. 

 

Turns out InDesign GREP is just too greedy and multiple grep approach seems to work smoother.

 

Translate
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
Explorer ,
Mar 07, 2025 Mar 07, 2025

Thank you FRIdNGE! I wouln't have been able to figure any of these out! 
Tried and it works but except for the number with the decimal place (I have numbers up to 1d.p.). 
Please could you tell me how I can add this? 
Screenshot 2025-03-08 at 07.18.39.png

Translate
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
Guide ,
Mar 08, 2025 Mar 08, 2025

Grep Style 1:  \(([\d.]+,\h){0}\K[\d.]+(?=.*\))

Grep Style 2:  \(([\d.]+,\h){2}\K[\d.]+(?=.*\))

Grep Style 3:  \(([\d.]+,\h){4}\K[\d.]+(?=.*\))

Grep Style 4:  \(([\d.]+,\h){6}\K[\d.]+(?=.*\))

Grep Style 5:  \(([\d.]+,\h){8}\K[\d.]+(?=.*\))

 

Capture d’écran 2025-03-08 à 09.18.52.png

 

(^/)

Translate
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
Guide ,
Mar 08, 2025 Mar 08, 2025

Capture d’écran 2025-03-08 à 09.35.30.png

 

Reading your screenshot, light version [ at your own risk!  =D ]:

 

(\(|[\d.]+,\h)\K[\d.]+(?=.*\))

 

(^/)

Translate
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
Explorer ,
Mar 08, 2025 Mar 08, 2025

Thank you very much! Very helpful 😄

Translate
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
Explorer ,
Mar 08, 2025 Mar 08, 2025

Working superbly well so far until I had a set of numbers AND a hyphen (-). How will I include to change numbers when it is numbers and -? 
Thank you so much 😄
Screenshot 2025-03-08 at 18.25.11.png

Translate
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
LEGEND ,
Mar 08, 2025 Mar 08, 2025

@Kyoko5CD0

 

Changing all: 

 

[\d.] 

 

into 

 

[\d.-]

 

should work. 

 

Translate
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
Explorer ,
Mar 08, 2025 Mar 08, 2025

@Robert at ID-Tasker Thank you so much 😄 😄 

Translate
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
LEGEND ,
Mar 08, 2025 Mar 08, 2025
quote

@Robert at ID-Tasker Thank you so much 😄 😄 


By @Kyoko5CD0

 

You're welcome 🙂 

 

So it's working? 😉 

 

Translate
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
Explorer ,
Mar 08, 2025 Mar 08, 2025

Yes! It is working like a magic. 👍👍

Screenshot 2025-03-08 at 19.54.48.png

Translate
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 ,
Mar 08, 2025 Mar 08, 2025

Great combo of efforts across the forums 

 

Interesting challenge

Translate
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
Explorer ,
Mar 23, 2025 Mar 23, 2025

So I am here again. Some font colours are very hard to see and I want to know if you can make the font bold alternatively like below. Please let me know what the additional GREP for making it bold. Thank you 😄

Screenshot 2025-03-24 at 06.40.49.png

Translate
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
Guide ,
Mar 24, 2025 Mar 24, 2025

No Grep change, just include the "bold" option in the adhoc char style settings.

 

(^/)

Translate
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
Explorer ,
Mar 24, 2025 Mar 24, 2025

Thank you! Worked 😄 😄

 

Translate
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
Guide ,
Apr 04, 2025 Apr 04, 2025
LATEST

New Global Grep Code on:

 

https://fridnge.com/text-alternate-coloring/

 

(^/)

Translate
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
Explorer ,
Mar 07, 2025 Mar 07, 2025

Thank you Eugene. Amazing!

 

Translate
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