Copy link to clipboard
Copied
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
(?<=\d)(st|nd|rd|th)\>
Copy link to clipboard
Copied
Try the following
(?<=\d)(?:th|rd|nd)
-Manan
Copy link to clipboard
Copied
This finds no match ...
Copy link to clipboard
Copied
Did you spcify a Character Style?
How? Show us the character settings.
Show us the GREP PANEL inside the paragraph style.
Copy link to clipboard
Copied
This should work
(?<=\d)(st|nd|rd|th)
(it also includes āstā for 1st)
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Add \> to the GREP
Copy link to clipboard
Copied
(?<=\d)(st|nd|rd|th)\>
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
2. Because I am a beginner š
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Positive Lookbehind
Formula
End of Word
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This help shall not help for a concrete situation. It shoul show you how to do it, Look into the bread crumbs behind the @-menu in the dialog.
For that purpose not find & replace is the best solution, use GREP as part of the Paragraph Style.
What do you want to say with your screenshot?
Copy link to clipboard
Copied
@jmlevy said that if his formula was not working it was because there was no space between 1910 and they.
I showed there was an ordinary space in the screenshot.
Copy link to clipboard
Copied
It should work, when a \> is put at the end, that means when it is at a wordās end.