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

Engaged ,
May 28, 2022 May 28, 2022

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

TOPICS
How to , Type

Views

164

Likes

Translate

Translate

Report

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

Adobe Community Professional , May 28, 2022 May 28, 2022
(?<=\d)(st|nd|rd|th)\>

Likes

Translate

Translate
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

Try the following

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

-Manan

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

This finds no match ... 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

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.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

This should work

 

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

 

(it also includes “st” for 1st)

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

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?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

Add \> to the GREP

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

EDIT: sorry, it works.

I was adding spaces between brackets and afterward. Ignore following paragraph. 

=====

This is also finding no match.

Attached is the screenshot of what I am doing, which should reply also to your comment above.

I am doing "Find Next" not yet "Change"

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

  1. You added a space between ) and \. Remove it.
  2. Why do you use Find & Replace? Make the GREP part of the Paragraph Style.

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

2. Because I am a beginner 🙂 

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

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? 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

Positive Lookbehind

Formula
End of Word

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

@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.

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

Willi's answer added "end of word". 

Do not know what your formula was missing.

Screenshot with hidden characters

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

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?

Likes

Translate

Translate

Report

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
Engaged ,
May 28, 2022 May 28, 2022

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.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

LATEST

It should work, when a \> is put at the end, that means when it is at a word’s end. 

Likes

Translate

Translate

Report

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