Finding Missing Spaces before Numbers

Written by Allen Wyatt (last updated April 17, 2021)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


10

Tracey proofreads loads of documents and was wondering how to find where a word and number have been combined accidentally as the space wasn't included, such as "and317." She wonders how she can perform Find and Replace to eliminate this issue.

This sort of task can be easily done with Find and Replace. First, let's say that you just want to find occurrences that you note—a letter followed immediately by a digit. You can do that by following these steps:

  1. Display the Find tab of the Find and Replace dialog box. (In Word 2007 just press Ctrl+F. In Word 2010 or later versions, press Ctrl+F to display the Navigation pane, then click the down arrow at the very right of the Search box in the Navigation pane, and finally choose Advanced Find.)
  2. In the Find What box, enter ^$^#. These codes tell Word you want to find any letter followed by any digit.
  3. Click Find Next.

At this point, Word will find and stop at the next occurrence of a letter followed by a digit. You can, at this point, make any edits desired and then continue searching.

For Tracey's purposes, though, it might be better to let Find and Replace do the heavy work. Follow these steps:

  1. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box.
  2. Click the More button, if it is available.
  3. Make sure the Use Wildcards check box is selected.
  4. In the Find What box, enter "([A-Z,a-z])([0-9])" (without the quote marks).
  5. In the Replace With box, enter "\1 \2" (again, without the quote marks). (See Figure 1.)
  6. Figure 1. Getting ready to find a letter followed by a digit and insert a space.

  7. Click on Find Next. Word finds the first occurrence.
  8. If you want to insert the space, click Replace. If you don't want to insert the space, click Find Next. Either way, Word finds the next occurrence.
  9. Repeat step 7 until Word reports it is through.
  10. Close the Find and Replace dialog box.

The key to these steps is steps 3 through 5. You are telling Word that you want to do a wildcard search. Then, in step 4, you are defining a pattern for what should be found. You are specifying that you want a letter in the range A-Z or a-z followed by a digit in the range 0-9. The inclusion of the parentheses in step 4 is very important, as they define matches that can be referenced in step 5. There, the \1 indicates you want to use whatever was matched by the pattern in the first set of parentheses in step 4, and \2 indicates you want the match from the second set of parentheses. Note that between these two there is a space, so the result is that you are inserting a space between the letter and the digit.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13848) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Selecting Noncontiguous Ranges with the Keyboard

It's easy to select non-contiguous ranges using the mouse, but may seem more daunting if you are simply using the ...

Discover More

Rounded Corners on Cells

As you are formatting a worksheet, Excel allows you to easily add borders to cells. Adding rounded corners to cells is a ...

Discover More

Forcing a Worksheet to be Protected Again

Excel allows you to protect your worksheets so they can only be changed as you want to have happen. If you unprotect a ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Replacing Highlighted Words

The Find and Replace capabilities of Word are quite powerful. Knowing how to find and replace highlighted text can be a ...

Discover More

A Fast Find-Next

Want a quick, easy way to "search again" for the next occurrence of what you need? Use the technique in this tip and ...

Discover More

Replacing and Renumbering

Word has a powerful find and replace capability that can help you perform quite a few changes to your documents. This tip ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 1?

2023-12-30 04:59:33

Falk

@Tomek:
Thanks for the insight. Of course: If formatting is not of importance one can always copy the text into, say, notepad++, and perform the search (and replace) operation there. Copy back the text into word afterwards.


2023-12-30 00:12:13

Tomek

@Falk:
For the example I gave in my previous comment, you can search for "alumin*um" but that is dangerous: it will find any text that will start with "alumin" and end with "um" even if the latter is 500 pages down in the document, as long as it did not find aluminum or aluminium earlier. So if your text starts with Silicoaluminate and ends with a word maximum, almost all text may be selected. Grrrr.

You cannot use "alumin?um" to find aluminum, the ? looks for exactly one letter.


2023-12-29 23:54:37

Tomek

@Falk:
"+" doesn't work in Word, you have to specify the number of occurrences in braces.
Also, Word doesn't accept 0 occurrences so for instance you cannot use (alumin)([i]{0,1})(um) to look for aluminum (American spelling) and aluminium (IUPAC spelling) in one search. Pity!


2023-12-29 07:32:12

Falk

@Tomek:
Ok - in Regular Expressions the "braces" allow you to give the exact number or a range of numbers the searched-for expression shall be present. {0,5} allows from none to five occurrences, {1,} looks for at least one occurrence to infinite number of occurrences. "+" does the exact same thing, but maybe Microsoft didn't import the entire syntax for RegExp...


2023-12-29 01:17:26

Tomek

@Falk:
instead of + (which doesn't work on my machine) you should use {1,}
i.e.,
([A-Z,a-z]{1,})([0-9]{1,})

@Pocok:
Use the above pattern, then \1 as replace pattern. This will remove all digits that follow a string of alphabetic characters.
You could also use:
([A-Z,a-z])([0-9]{1,}) combine with \1. This will remove all digits after any alphabetic character (may be just the last one of the preceding word).

There are two things you may need to pay attention to:
1. If the digits are followed by a word without intervening space, the two words will be joined without being separated by space. If this is a problem, use "\1 " as the replacement pattern, then separately look for double spaces and replace them with a single one.
2. If you use other languages, you may need to include language-specific characters like á ß ç ñ ü ą ł č, etc in the list of characters to search for.


2023-12-26 10:35:26

Andrew

Pocok - you simply remove the "\2" from the Replace-With text ("\2" in this case standing in for whatever text matched the second set of parentheses in the Find-What text.


2023-12-25 17:35:29

Pocok

Hello, I would like to build upon this: Using the ([A-Z,a-z])([0-9]) I've found what I needed, however I want to REMOVE the digits from this combo, how can I do that in the Replace segment?


2021-04-19 12:23:08

Falk

If, as the character pattern suggest, we are dealing with 'regular expressions', a '+' after the right brackets ']' respectively might help in selecting the entire number as well as the entire following word in question. Like so:
([A-Z,a-z]+)([0-9]+)
Haven't tried this out though.


2021-04-19 10:21:07

Martyn Crawford

Seems that this only works on the letter and number that are next to each other, not on the entire letters string and the entire numbers string. This means that using "\2 \1" instead of "\1 \2" only swaps and separates those middle two characters.


2021-04-18 04:59:04

Falk

Thanks for hint on the "wildcard" approach - I didn't know about this feature. One little drawback of the presented solution is, that it will not work as desired on all languages. The "regular expression" used in the "Find" textbox only catches normal english alphabet letters from a to z, capitalized or not. In many languages, however, there are letter accents, like the German "Umlaute" (ä,ö,ü) or the French accents (e.g. é, è, ê). Of course, the regular expression can then be expanded to fit the needs of the language used.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.