Skip to main content
Inspiring
May 28, 2022
해결됨

GREP: how to find "th" "rd" "nd" after a number?

  • May 28, 2022
  • 2 답변들
  • 3457 조회

I need to filter all the "th" "rd" "nd" after a number in a story to apply the Superscript character style to them. 

I tried "\n" (any number) followed by "th" (all without quotes), but it didn't work.

Tried separating them with commas "\n,th" or with braces, brackets [\n]th {\n}th but no luck.

What am I missing here? 

Could you also suggest a handbook for GREP?

Thank you

최고의 답변: Willi Adelberger

Add \> to the GREP


(?<=\d)(st|nd|rd|th)\>

2 답변

jmlevy
Community Expert
Community Expert
May 28, 2022

This should work

 

(?<=\d)(st|nd|rd|th)

 

(it also includes “st” for 1st)

Inélsòre작성자
Inspiring
May 28, 2022

This is better but it also finds me the instance "1910 they" because there is a number before th.

Could we refine this so that there is no space between the number and the letters?

Inélsòre작성자
Inspiring
May 28, 2022
(?<=\d)(st|nd|rd|th)\>

Could you please explain how this is working?

I understand the (st|nd|rd|th) part where | is the bitwise OR operator.

\d is "any digit", but what about the rest? 

Community Expert
May 28, 2022

Try the following

(?<=\d)(?:th|rd|nd)

-Manan

-Manan
Inélsòre작성자
Inspiring
May 28, 2022

This finds no match ... 

Willi Adelberger
Community Expert
Community Expert
May 28, 2022

Did you spcify a Character Style?

How? Show us the character settings.

Show us the GREP PANEL inside the paragraph style.