Find and Replace Ordinal Numbers using Superscript in InDesign


In this article, you will learn how to automate superscripting the letter portion of 1st, 2nd, 3rd etc in your InDesign document using Find/Change and GREP.

As a developer, I always think about reducing repetition (DRY, anyone?).

So, not surprisingly, when tasked with a repetitive styling task in an Adobe InDesign manuscript, I’m quick to use Find/Change, specifically the GREP tab options.

Recently, I needed to search a 700+ page InDesign document for any time 1st, 2nd, 3rd, 4th, 100th, 59th, etc was included and to change the letter formatting to superscript. This task is perfect for programming.

Code Snippet to Search InDesign for 1st or 2nd and other Ordinal Numbers

First, I wanted to query and find instances of ordinal numbers (1st, 2nd, etc) in my document. To do this I used a custom query in the Find/Change area of InDesign.


This GREP code snippet queries your document for where there are instances of th, st, nd, or rd with a number before them.

Using GREP in the InDesign Find/Change Box

First, select Edit > Find/Change or use Command + F on a Mac.

By default, in Find/Change you’ll have the Text tab selected. Choose the GREP tab. Next, copy and paste the code snippet into the Find What: field.

In my case, I want to change the letters to superscript, so I will use the Change Format field, too. Click the T with the magnifying glass icon (labeled Specify Attributes to Change) on the right in the Change Format area. This will bring up a Change Format Settings window. You’ll want to navigate to Basic Character Formats on the left. Then, choose Superscript from the drop-down options for Position.

Set Superscript in Change Format by doing the following: Click the T with the magnifying glass icon in the Change Format area. This will bring up a Change Format Settings window. You'll want to navigate to Basic Character Formats on the left. Then, choose Superscript from the drop-down options for Position.

Once this is completed, you’ll be ready to start searching and replacing. Your Find/Change settings should look like this screenshot.

Find/Change 1st, 2nd, 3rd, 4th and more in InDesign using (?<=\d)(th|st|nd|rd)\> and format change to +superscript
Find/Change 1st, 2nd, 3rd, 4th and more in InDesign using (?<=\d)(th|st|nd|rd)> and format change to +superscript

I often search my document for ordinals, one by one, using the Find Next button. If it’s an instance I want changed, I click the Change button and go to the next one; however, you can use the Change All button and save lots of time in large documents.

Search is completed. Adobe InDesign - Change All option.

And that’s it. Success.

Video showing how to Find and Change 1st, 2nd and 3rd to Superscript in InDesign

So today, we’re going to be looking at how you use

find and change in InDesign to quickly superscript

numbers like we have here,

2nd, 1st, 3rd, 4th,

94th – ordinals.

Alright so what we’re going to do is say edit,

find change that can also be command F.

Alright it defaults to text, we’re going to change to GREP.

And here is the code we’re going to use and you can find that

in the description. And what it does is it’s going to query your document

for TH, ST, ND or RD that follow

a numeral. Alright so that’s going to be the search

that’s going to be able to find,

if I click forward,and I say find next,

it can find “2nd”

Alright I’m going to go backwards, find previous.

I can see this in ND is not superscript.

So the setting we’re going to do is in change format.

We’re going to click the icon “specify attributes to change” and

then we’re going to click the second basic character format and under position choose

superscript. Alright. Sometimes it’s moody.

I’m going to say okay and try again. There

we go. It worked that second time. Alright.

So now when I say find previous it has selected and

I can click change. And you’ll see it has become a superscript.

So I have the query looking for examples of these ordinals and then when

I change it is going to change just the letter part, which is what’s

selected to superscript. Alright so let’s look again.

Here’s another one. Change. Find previous change.

Find previous change. So this is something that could

be automated to do all.

Or I like to do it one by one to make sure that I’m

not breaking anything. You can see now it found a fourth.

Find previous. It’s found a third. So I can quickly go through large documents.

And in this case I have 700 plus pages that I am looking for

instances of these. And I can make it consistent across my entire document

using this GREP formula.

Alright, I hope this helps you. And saves you a lot of time.

Thanks for watching.

Try it yourself

You can try superscripting the ordinals in InDesign by copying and pasting the paragraphs below or downloading our sample InDesign document.

Download a test INDD file to run this GREP script for Find and Replacing ordinals with superscript ordinals
On the 20th day of the month, under the azure sky, a procession of regal carriages traversed the cobblestone streets. Each carriage, adorned with intricate golden filigree, bore nobles clad in resplendent attire, attending the grand anniversary celebration. The town square, bustling with fervent activity, welcomed guests from the four corners of the kingdom, eager to partake in the festivities. Amidst the jubilant throng, the 21st Duke of Westshire stood at the forefront, a beacon of prestige and grace, as he addressed the assembled multitude, commemorating the 25th year of his esteemed reign.

In the shimmering ballroom of the grand palace, adorned with a myriad of crystal chandeliers, the illustrious event unfolded. Tables, draped in satin cloths of royal blue, were meticulously arranged, each bearing an array of delectable delicacies. Dancers moved in synchrony to the 24th waltz, their graceful movements mirroring the elegance of the occasion. At the stroke of midnight, as the clock chimed the 30th hour, the Duke, accompanied by the 26th Duchess of Westshire, raised a crystal goblet in a toast to prosperity, marking the culmination of a truly remarkable celebration.

Questions and Resources

What are Ordinal Numbers?

Ordinal numbers are numbers used to represent order; this could also be rank or position, such as first, second, or third.

Where can I learn more about how to make GREP changes in InDesign?

David Platner writes more about using GREP in InDesign, specifically on this topic, in his post Quick GREP To Superscript Ordinals.

What is GREP in InDesign?

GREP is a code snippet. It can also be called an expression or a formula. GREP stands for Global Regular Expression Parser.

I hope this helps you speed up superscripting the letters in your ordinal numbers — like 1st, 2nd, and 3rd.

Happy Designing!

About the author

Kelly Barkhurst

Designer to Fullstack is my place to geek out and share tech solutions from my day-to-day as a graphic designer, programmer, and business owner (portfolio). I also write on Arts and Bricks, a parenting blog and decal shop that embraces my family’s love of Art and LEGO bricks!

Add comment

Recent Posts