In a comment on another blog post, one of my readers asked if there was an easy way to find all numbers and change them to italic. Well, there is (Option 1 below), but there was a further complication—some of these numbers were a range separated by a dash, and some were separated by commas. For example:
- (123456)
- (1-4)
- (1, 5)
- (1, 5, 12)
I couldn’t find an easy way to do this all at once, but you can do it by running several wildcard find and replace routines. If someone else has an easier or more elegant solution, please add it in the comments.
NOTES:
- Tip: Just in case anything goes wrong, make a copy of your document before you start and do this in the copy until you are satisfied it works as you expect.
- Tip: Only click Replace all once you are confident that it works.
- Numbers are whole positive integers—no decimals, no ordinals, no negative numbers.
- ‘Dash’ is the standard hyphen character on the keyboard, NOT an en or em dash, or a minus symbol.
- All find and replace routines are done with Use wildcards turned on (Ctrl+h, click More, select Use wildcards).
- Tip: Copy the find strings from here and paste into your Word find field.
Option 1: Find all numbers and change to italics
- Find: ([0-9])
- Replace: \1
- When in the Replace field, click Format > Font, and choose Italic.
Note: EVERY number in the document will be italicised.
Option 2: Find whole numbers only inside parentheses and change to italics
For example: (123456), (789), (23)
- Find: \(([0-9]@)\)
- Replace: ^&
- When in the Replace field, click Format > Font, and choose Italic.
Note: The numbers AND their surrounding parentheses will be italicised. See Option 6 for how to change the parentheses back to normal text.
Option 3: Find whole numbers separated with a single dash inside parentheses and change to italics
For example: (12-3456), (7-89), (2-3) [there are NO spaces before or after the dash]
- Find: \(([0-9]{1,9})(-)([0-9]{1,9})\)
- Replace: ^&
- When in the Replace field, click Format > Font, and choose Italic.
Note: The number ranges, the dashes, AND their surrounding parentheses will be italicised. See Option 6 for how to change the dash and the parentheses back to normal text.
Option 4: Find 2 numbers separated by a comma and a space, inside parentheses, and change to italics
For example: (1, 2), (25, 67)
- Find: \([0-9]{1,9}, [0-9]{1,9}\)
- Replace: ^&
- When in the Replace field, click Format > Font, and choose Italic.
Note: The numbers, the comma, the space, AND their surrounding parentheses will be italicised. See Option 6 for how to change the comma, space, and the parentheses back to normal text.
Option 5: Find 3 numbers separated by commas and spaces, inside parentheses, and change to italics
For example: (1, 2, 3), (25, 67, 345)
- Find: \(([0-9]{1,9}, [0-9]{1,9}, [0-9]{1,9})\)
- Replace: ^&
- When in the Replace field, click Format > Font, and choose Italic.
Note: The numbers, comma, spaces, AND their surrounding parentheses will be italicised. See Option 6 for how to change the commas, spaces, and the parentheses back to normal text.
Option 6: Change all commas, spaces, dashes, and parentheses back to normal text
- Find: ([, \(\)-]) (Note: there’s a space after the comma in this string)
- When in the Find field, click Format > Font, and choose Italic.
- Replace: ^&
- When in the Replace field, click Format > Font, and choose Not Italic.