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

@Inélsòre 

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

If my query finds “1910 they”, it is because there is no space between “1910” and “they”. Otherwise, it only finds “th”, “st”, “rd” and “nd” when there is a digit before but not if there is a space before.


Willi's answer added "end of word". 

Do not know what your formula was missing.

Screenshot with hidden characters

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.