h1

Word: Italicise numbers inside parentheses

December 2, 2021

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

  1. Find: ([0-9])
  2. Replace: \1
  3. 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)

  1. Find: \(([0-9]@)\)
  2. Replace: ^&
  3. 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]

  1. Find: \(([0-9]{1,9})(-)([0-9]{1,9})\)
  2. Replace: ^&
  3. 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)

  1. Find: \([0-9]{1,9}, [0-9]{1,9}\)
  2. Replace: ^&
  3. 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)

  1. Find: \(([0-9]{1,9}, [0-9]{1,9}, [0-9]{1,9})\)
  2. Replace: ^&
  3. 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

  1. Find: ([, \(\)-]) (Note: there’s a space after the comma in this string)
  2. When in the Find field, click Format > Font, and choose Italic.
  3. Replace: ^&
  4. When in the Replace field, click Format > Font, and choose Not Italic.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: