Word: Insert a space between a number and a letter

February 8, 2012

A document I edited the other day was peppered with hundreds of values followed immediately by the unit of measure (e.g. 5km, 20mm, 50m/s etc.). Our house style follows the Australian Style Manual, which is to have a space between almost every value and its unit of measure (e.g. 5 km, 20 mm, 50 m/s).

While I could run several find and replace (F/R) passes looking for various measurement units (e.g. km) and then replacing them with a space followed by the measurement unit, there were a LOT of different units used and some, such as ‘m’ for meter, weren’t easy to catch using the normal F/R methods — either that, or I caught more than I wanted and ended up with two spaces in front of any word starting with ‘m’. Doing 20+ passes of F/R hoping to get most of the measurement units didn’t seem like a lot of fun.

So I applied some of the knowledge I’ve learned recently about wildcard F/R to catch them all. I still had to replace them one at a time as I needed to avoid adding a space between legitimate instances of numbers followed by a letter (e.g. chemical symbols such as H2S). But using the wildcard search made it much easier to find every instance of a number followed immediately by a letter, and replace the relevant ones with the same number followed by a space then the same letter.

Here’s how:

  1. Open Word’s Find and Replace dialog box (Ctrl+H).
  2. Click More to show more options.
    Find and Replace dialog - click the More button
  3. Select the Use wildcards check box.
    Find and Replace dialog - select Wse Wildcards
  4. In the Find what field, type: ([0-9])([A-z])
  5. In the Replace with field, type: \1 \2
    Note: There’s ONE space immediately after the \1, so make sure you type that too.
  6. Click Find Next, then click Replace to insert a space into each one that’s relevant. Repeat until you’ve done them all.

Explanation for how this works:

  • ([0-9]) looks for any numeral. This string defines the first section of the Find. Because you are using wildcards, you need to surround the characters you want to find in parentheses. The square brackets indicate a range — in this case any numeral from 0 to 9 will be found.
  • ([A-z]) looks for any letter, upper or lower case. This string defines the second section of the Find. Again, you define the range of letters to be found with square brackets; the [A-z] means any upper case letter from A through the lower case letters to z.
  • \1 replaces the first part of the wildcard string with itself. In other words, the numeral found is replaced with itself, so no change apparently occurs.
  • The single space after \1 replaces adds a space between the two parts found.
  • \2 replaces the second part of the wildcard string with itself. In other words, the letter found is replaced with itself, so no change apparently occurs.

However, what I couldn’t figure out how to do was make the space I inserted a non-breaking space. In a normal F/R, I’d use ^s for a non-breaking space, but I couldn’t figure out how to add that successfully to the Replace field. Anything I tried just put in ^s or (^s) as text, NOT as a non-breaking space. Anyone know how?

See also:

[Links last checked August 2012]


  1. Nice tip.
    \1^s\2 by itself in the “Replace with:” field works for me on Word 2007.
    I did one replace with this string, and then one with a plain old space and turned on paragraph marks, and I had one of each.

  2. Brilliant! Thanks Jay. I was obviously overthinking this and assuming that ‘Use wildcards’ somehow applied to the stuff in the Replace field.

    Thanks for contributing.


  3. Hi Rhonda
    I tried using this wildcard Find and Replace, and for some reason a space was inserted after the letter rather than between the number and the letter. Any thoughts?

  4. Hi Chris

    Make sure you put the space between \1 and \2 in the Replace field, and make sure there are no spaces after the \2 too.

    I have used this hundreds of times with no issue, but if you don’t put the space in the correct place, you won’t get what you intended.

    If you want a non-breaking space between the numeral and the letter, then put this in the Replace field: \1^s\2 (the ^s must be a lower case ‘s’).


  5. Awesome… thanks…

    Helped me to figure out my problem as I only had letters

    If you want spaces between letters only:

    – find what: ([A-z])([A-z])
    – replace with: \1 \2
    – typed as: slash-1-space-slash-2-space-space

    And I can just remove extra spaces as some had one and two spaces :)

  6. HI Marina

    Wouldn’t that put a space between EVERY letter in every word?


  7. Hi Rhonda,
    I was having the same problem as Chris. Even using a non-breaking space in the replace field : \1^s\2
    was being replaced as: \1\2^s

    The problem seems to be associated with the ‘track changes’, function. Once I turned ‘track changes’ off, then the Find and Replace worked as expected.

  8. Thanks for sharing, David. I would never have thought that Track Changes would affect this, but it doesn’t surprise me as it affects lots of other things that go a bit awry too.


  9. Hi Rhonda,
    I tried to use this as a basis for finding unspaced ellipses and replacing with spaced ellipses, thus:
    Find: ([a-z])(…)([a-z])
    Replace: \1 \2 \3

    But it wouldn’t work!! Can you see what I’m doing wrong and how I should do it correctly?


  10. Hi Carol

    That’s likely because Word automatically converts three periods into an ellipsis, which is a different ‘character’ altogether from three separate periods (there’s a default autocorrect setting for this).

    To get what you want, use everything you have already tried, but instead of typing three periods in the second string of the Find, type Ctrl+Alt+, which is the keyboard shortcut for an ellipsis.

    You should find it now works.


  11. Thank you so much for this. I have the exact same problem as you, and this saved me so much work.

  12. I give you all the Internets in thanks good sir, this done in 10 mins what would have taken hours otherwise.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: