Skip to main content
Participant
February 15, 2021
Answered

GREP style for specific digits

  • February 15, 2021
  • 3 replies
  • 1720 views

Hi all,
I'm working on a book and I'm having an issue with GREP. I have a list of excercises in a following manner (to be clear - Zad. is a shortcut from 'Zadanie', meaning an 'Exercise' in English):

Zad.1 (main exercise)

Zad.1.2 (secondary exercise)

Zad.1.3

Zad.2 ... etc

Analogically, I have 2-digit numbers exercises: Zad.10, Zad.10.1, Zad. 10.2 etc. and 3 digit: Zad.100., Zad.100.1, Zad.100.2, Zad.101.
I would like to change "Zad." to a specific character style, only if it's followed by a secondary exercise. Wrote 3 greps:

But only first two are working properly. Any idea why the third one don't change the font?

Thanks

This topic has been closed for replies.
Correct answer vladan saveljic

However in your case you don't need 3 grep style.

One grep style is enough

Try this grep

Zad\.(?=\d{1,3}\.\d+)

or this one

Zad\.(?=\d+\.\d+)

3 replies

vladan saveljic
Inspiring
February 15, 2021

You have to insert "\" before any dot "."

the dot "." without "\" means any character

In your case for example your second grep style Zad.(?=\d\d.\d) means find Zad + any character with positiv lookahead any digit + any digit + any character

In this case your grep style finds Zad.108 too

vladan saveljic
vladan saveljicCorrect answer
Inspiring
February 15, 2021

However in your case you don't need 3 grep style.

One grep style is enough

Try this grep

Zad\.(?=\d{1,3}\.\d+)

or this one

Zad\.(?=\d+\.\d+)

Participant
February 15, 2021

Thank you for a help! Worked!
Jakub

vladan saveljic
Inspiring
February 15, 2021

Maybe I didn't understand your issue.

Zad.3.1

Zad.3.2

Zad.12.1

Zad.12.2

Zad.108.1

Zad.108.2

On your screenshot I see that all this cases are in Comic sans

I missed something?

Participant
February 15, 2021

I have a whole book made with a Lato font. I need to change prefixes: "Zad." to a specific character style (e.g. Comic Sans - it doesn't matter for now), only if they stand before secondary exercieses (x.1, x.2 etc). With the GREPs I sent above, it works only for one-digit and two-digit. In three-digit examples (see the screenshot) - it doesn't. The main exercise number is being changed to Comic. I need it to stay in Lato (as on two first screenshots). Any ideas for that?
Sorry maybe I posted my question wrongly.

Jakub