Easy to solve using regular expressions:
- Preferably, create a character style that has underscript.
- Open the Find and Replace dialog (the default shortcut is Ctrl+H).
- Check the Regular Expression Option under ‘Other options’.
- Type the following regular expression in the ‘Find’ textbox (See explanation bellow!):
(?<=\b[[:upper:]])(\d+)\b
- Click the Find All button.
- Now that all the targetted numbers are selected, apply the style you created in step 1, or apply direct formatting (not recommended!)
Done!
Explanation for the regular expression:
I wrote the expression so that it will be able to match any number of digits for any uppercase letter. It has two parts:
the look-behind part:
(<=\b[[:upper:]])
Whatever is going to be matched must be preceded by an uppercase letter with nothing but punctuation or white space before it.
and the matching part:
(\d+)\b
Matches all ocurrences of numbers of any size followed by nothing but space or punctuation.
Check out ICU Regular Expressions if you wish to know more.