Word replace any number

MS Word is a powerful word processing tool from Microsoft. At times we find ourselves in a situation wherein we need to find and replace numbers in a Word document. It is quite easy to accomplish this using Find and Replace facility given in MS-Word. Here is how we can do this.

Open the document where replacement is to be done.

Press CTRL + H keys to bring Find and Replace box up.

Now, in Find what box type ([0-9])

MS Word: Find and Replace Numbers, Digits, Numerals

MS Word: Find and Replace Numbers, Digits, Numerals

Click on More >> button to reveal more options for Find and Replace.

In the extended box, select Use wildcards

Now press Find button and MS Word will find you the first number (i.e. any digit from 0 to 9) in the document. Please note that it will find each digit individually, that is to say that if 2012 is written in the document –this search will find four digits and not 2012 as a whole number.

Our tips on MS-Word make your life easier and increase your productivity at work.

It is very important that you select Use wildcards because this will enable MS Word to understand your search demand.

If you want to delete all the numbers from your document, just keep the “Replace with” box empty and click “Replace all”… this action will effectively replace every numerical digit with nothing.

SEE ALSO: How to Replace Images in MS Word

If you want to replace only certain digits, you can alter the search query. For example, if you want to find only 4, 7 and 9 you should write the following in “Find what” box:

([4,7,9])

If you want to look only for digits from 1 to 4, you can use either of the following expression:

([1,2,3,4])

Or

([1-4])

In the “Replace with” box, you can write whatever you want to replace the found text with. Easy!

So, this was the solution. I hope it was useful! You can see a lot of other MS Word Tips on TechWelkin.

Please feel free to post your questions, if case you have any, in the comments on this article. Thank you for using TechWelkin.

Image of Susan Harkins

on

March 30, 2022, 11:21 AM PDT

How to specify single- and double-digit values using the Replace feature in Word

Any time a Microsoft Word’s Find & Replace task goes beyond literal values, you might need wildcards. Susan Harkins will show you how to use these handy devices.

Microsoft Word and Excel app on the display notebook closeup. Microsoft Office is an office suite of applications created by Microsoft.
Image: prima91/Adobe Stock

Most of us learn how to use Microsoft Word’s Find & Replace feature early on because it’s so easy and helpful. However, sometimes a task is complex enough to send us back to the drawing board. For example, you might think replacing numbers comprised of only one or two digits impossible, but it isn’t. Thanks to a few wildcards, you can accomplish this in only one run. In this article, I’ll show you the wildcard string that will find all numbers consisting of only one or two digits.

SEE: Software Installation Policy (TechRepublic)

I’m using Microsoft 365 on a Windows 10 64-bit system, but you can use an earlier version. I recommend that you hold off on upgrading to Windows 11 until all the kinks are worked out. For your convenience, you can download the demonstration .docx  file. However, it’s a simple list of one-, two- and three-digit numbers that you can easily create yourself.

The Replace string

Let’s keep the Replace string simple. Specifically, let’s add text to the beginning and the end of each number. Doing so lets us see where things work and don’t work. We’ll be working with a simple set of numbers, shown in Figure A. The simple list contains single-, double- and triple-digit numbers.

Figure A

We’ll use this list of simple numbers in Word to test several find strings.

We want to ignore any number comprised of more than two digits. To that end, we’ll work with the following replace string:

pre^&sub

If Word finds the number 03, this Replace string will return pre03sub.

How to find numerical digits

To replace or modify existing numerical values comprised only of one or two digits, you need wildcards. You could consider simplifying the task by running two different replace tasks: one that finds only single-digit numbers and one that finds only double-digit numbers. Fortunately, you can easily combine both searches into one.

The first wildcard component we’ll try is [0-9], which finds any digit.

Now, let’s work through the first Find string:

  1. On the Home tab, click the Editing option and click Replace. Or press Ctrl + h.
  2. In the resulting dialog, enter [0-9] as the Find What string.
  3. Enter pre^&sub as the Replace With string.
  4. If necessary, click More.
  5. Check the Use Wildcards option shown in Figure B.
  6. Click Replace All and then OK to close the information prompt.

Figure B

Click Use Wildcards in Word.

Click Use Wildcards in Word.

As you can see in Figure C, this Replace task added the Replace With string to every digit, not every number. That means we need a wildcard that matches a single word. In this case, word includes numbers. If you’re working with the demonstration file, be sure to press Ctrl+Z to undo the changes made by running Replace before you continue to the next wildcard example.

Figure C

The Word Find string needs a bit of work.

The Word Find string needs a bit of work.

Fortunately, there is a wildcard that can handle this particular find requirement: <>. By enclosing the [0-9] string in <> characters, Word will interpret combined digits as a whole word. Let’s add the <> characters and try again.

  1. Press Ctrl + H.
  2. The Replace feature remembers the last task, so you don’t have to enter the strings from scratch. Instead, insert the < and > characters, as shown in Figure D.
  3. Click Replace All and OK.

As you can see in Figure D, we’re a bit closer. Word ignores the three-digit numbers, but it also ignores the double-digit numbers. Don’t forget to press Ctrl + Z to undo the changes before you continue.

Figure D

Word ignores digits with more than on digit.

Word ignores digits with more than one digit.

We need a way to specify double-digit numbers while ignoring numbers with more than two digits. That’s where the next wildcard comes in: {}. This wildcard specifies any sequences of digits, which you specify. {1,} would find single-digit numbers; {1,2} will find only single- and double-digit numbers. Let’s add it to our existing Find What string and see what happens:

  1. Press Ctrl + H.
  2. Tack the {1,2} wildcard component to the end of the Find What string, as shown in Figure E.
  3. Press Replace All and then OK.

Figure E

Finally, the Find What string works.

Finally, the Find What string works.

Success! This Find What string meets every requirement. Let’s review the wildcards we used and what they do.

A quick review of wildcards in Word

Let’s take a minute to review what each wildcard does:

  • [0-9] specifies all digits. If you used [0-3], Word would find only the digits 0 through 3.
  • <> limits the search to single words. Subsequently, <[0-9]> won’t treat numbers consisting of more than one digit as a bunch of individual digits.
  • {} lets you specify a sequence of digits; {1,2} will find numbers that consist only of one or two digits.

By combining these three wildcards, <[0-9]{1,2}> you’ll find only numerical values that consist of one or two digits. Once you know how the wildcards work, it’s easy to come up with this string so you can run only one Replace task.

Also See

  • Windows 11 cheat sheet: Everything you need to know
    (TechRepublic)

  • Checklist: Securing Windows 10 systems
    (TechRepublic Premium)

  • More must-read Microsoft coverage
    (TechRepublic on Flipboard)

  • Training: Don’t overlook the importance of Microsoft Word
    (TechRepublic Academy)

  • Top Power BI Alternatives | Compare Power BI Competitors
    (TechRepublic)

  • Microsoft

  • Software

Trying to do a find a replace on any paragraph that begins with a number.

Tried this in Find and Replace:

Find what:
(^13)(^#)

But get the error

^# is not a valid special character for the find what box or is not
supported when the Use Wildcards check box is selected.

Update:
Forgot to mention that my Use Wildcards box is checked in the search options. I am attempting to replace styles based on paragraphs that start with numbers.

asked Apr 2, 2013 at 16:15

kbeal2k's user avatar

kbeal2kkbeal2k

1131 silver badge4 bronze badges

I’m not clear whether you’re trying to do a Microsoft Word “Find and Replace”,
or whether you’re trying to use the Find function to find paragraphs that begin with numbers,
so you can then edit them manually. 
If it’s the latter, why not just turn off “Use wildcards” and search for ^p^# or ^13^#?

answered Apr 2, 2013 at 20:53

Scott - Слава Україні's user avatar

1

try <[0-9]{1,} for checking for numbers. if you know there is an upper limit to the number of characters the numbers will be you can change it to {1,4} for example and it will search for any number between 0 and 9999 including 0000.

That will check the beginning of words for one or more numeric characters

answered Apr 2, 2013 at 16:30

Snowburnt's user avatar

SnowburntSnowburnt

4312 silver badges7 bronze badges

Find and Replace Text and Numbers in Word

by Avantix Learning Team | Updated March 7, 2022

Applies to: Microsoft® Word® 2013, 2016, 2019, 2021 or 365 (Windows)

You can find and replace in Word using the Find and Replace dialog box as well as the Navigation Pane. If you use the dialog box, you can find and replace text and numbers and use wildcards for more advanced find and replace tasks. Wildcards are useful when you are not able to find an exact match. You can display the Find and Replace dialog box using a keyboard shortcut or the Home tab in the Ribbon.

Recommended article: How to Quickly Remove Hard Returns in Word Documents

Do you want to learn more about Microsoft Word? Check out our virtual classroom or in-person Word courses >

Note: Screenshots in this article are from Word 365 but are similar in previous versions of Word.

The Replace command appears on the Home tab in the Ribbon in the Editing group:

Replace command on Home tab in the Ribbon to find and replace words or characters.

Using the Find and Replace dialog box to replace words or characters (and match case)

You can perform simple find and replace tasks using the Replace dialog box in its collapsed state. To access more advanced options, you will need to click More in the Replace dialog box to expand it.

To use the Find and Replace dialog box to find and replace text in Word (words or characters) and match case if needed:

  1. Click the Home tab in the Ribbon.
  2. In the Editing group, click Replace to display the Replace dialog box. Alternatively, press Ctrl + H if you prefer to use a keyboard shortcut to open the Replace dialog box.
  3. Enter the text you want to find in the Find What box. You can specify whether Word should locate only matches with the exact capitalization by clicking More and then selecting or checking Match case.
  4. Enter the text you want to replace in the Replace box.
  5. Click Find Next and then click Replace for each occurrence or click Replace All.
  6. Click Close.

In the following example, the Replace dialog box has been expanded to display other options including Match case:

Replace dialog box in Word to find and replace using exanded options.

Finding and replacing using wildcards

To use wildcards, you will need to use the Find and Replace dialog box and expand it to display more options. You can then select the option to Use wildcards. A wildcard can replace one or more characters in a string of text or numbers. The most common wildcard is the asterisk (*).

It’s important to note that wildcard searches are case sensitive. Also, Word uses «lazy» pattern matching so it will stop matching as soon as possible. This means that you could enter part of a word and find that part without using wildcards.

To find and replace text using wildcards in Word:

  1. Position the cursor at the location in the document where you want to start finding and replacing. If you want to start at the beginning of the document, you can press Ctrl + Home.
  2. Click the Home tab in the Ribbon.
  3. In the Editing group, click Replace. Alternatively, press Ctrl + H. A dialog box appears.
  4. Select More to expand the dialog box.
  5. Click in the Find What box.
  6. Select or check the Use wildcards checkbox.
  7. Enter the text and wildcard(s) you want to use. For example, enter s*l to find any text starting with s and ending with l.
  8. Click in the Replace with box.
  9. Enter the text you want to use to replace the text in the Find what box.
  10. Click Find Next to find the first instance of the characters you want to find.
  11. Click Replace or Replace All. If you click Replace, Word will select the next matching characters in the Find what box. If you click Replace All, Word will display a dialog box with the number of replacements. In this case, click OK.
  12. If necessary, click Replace again. Repeat for each instance.
  13. Click Close to close the dialog box.

In the following example, b*s has been entered in the Find what box to find any word starting with starting with b and ending with s:

Find and replace in Word using the Replace dialog box and wildcards.

If you want to undo a Replace or Replace All action, close the dialog box and press Ctrl + Z.

Using common wildcards

The most common wildcards you can use in the Find and Replace dialog box are the asterisk (*) to find multiple characters and the question mark (?) to find a single character.

For example:

b*l will find ball and barrel (a character followed any characters and ending with a specific character)

h?ll will find hill and hall (a character followed by any single character and then followed by 2 characters)

Using wildcards to find one or more instances of the same character

You can also use @ as a wildcard to find one or more instances of the same character.

For example:

catchal@ will find catchal or catchall

Using wildcards for alternate characters and ranges

You can also use wildcards to find alternate characters or ranges of characters. These are entered in square brackets [ ] and may be combined with other wildcards.

[ ] can be used to find each of a set of characters

[ – ] can be used to find each of a set of characters in a range

You can use any character or series of characters in a range within the square brackets (including the space character). Characters are processed in alphanumeric order from lowest to highest.

For example:

[abc] will find any of the letters a, b, or c

[G] will find the upper case letter G

[A-Z] will find any upper case letter

[0-9] will find any single number

[13579] will find any odd number

[0-9A-z] will find any number or letter

f[ai]n will find each of the characters in square brackets such as fan or fin

[b-f]at will find each of a range of characters such as bat, cat, and fat

Using wildcards to omit characters

If you want to omit specific characters, you can use an exclamation mark (!) combined with square brackets.

For example:

[!f]ast will find last and past but not fast

Using wildcards to find the beginning or end of a word

You can use the less than symbol (<) to find the beginning of a word and the greater than symbol (>) to find the end of a word. These wildcards are combined with characters in round brackets or parentheses.

For example,

<(watch) will find watching or watchman

(all)> will find wall or stall

These wildcards can be problematic if you are using a wildcard and you want to find > or < as characters in the document. If this is the case, enter a backslash () in front of the character so that it is not treated as a wildcard.

For example,

<*> will find <h1> or <h2>

Using wildcards to find instances of a character

You can use curly brackets { } to specify the number of instances of a character. These brackets can be combined with a comma to specify the number of instances. Counting can be used with individual characters or with sets of characters.

{n} is used to find the number of instances of a character

{n,} is used to find at least n instances of a character

{n,m} is used to find between n and m instances of a character

For example:

^p{2} will find two consecutive paragraph marks or hard returns (^p is a special character for a paragraph mark in Word)

{3} will find three spaces (there is a space entered before the first curly bracket)

30{2,} will find at least 2 instances of the preceding character such as 3000 or 30000

30{3,4} will find between 3 and 4 instances of the preceding character such as 30000 or 300000 not 300

These last wildcards are particularly useful if you are finding and replacing numbers in Word.

The Find and Replace dialog box offers more functionality as well. For example, you can also Find and Replace Formatting in Word.

Subscribe to get more articles like this one

Did you find this article helpful? If you would like to receive new articles, join our email list.

More resources

How to Add Page Numbers in Word (Step by Step)

How to View Document Statistics in Microsoft Word

How to Update All Figure Numbers in Microsoft Word

How to Check Word Count in Microsoft Word (4 Ways)

How to Superscript or Subscript in Word (with Shortcuts)

Related courses

Microsoft Word: Intermediate / Advanced

Microsoft Word: Designing Dynamic Word Documents Using Fields

Microsoft Word: Long Documents Master Class

Microsoft Word: Accessible Word Documents

Microsoft Excel: Intermediate / Advanced

Microsoft PowerPoint: Intermediate / Advanced

VIEW MORE COURSES >

Our instructor-led courses are delivered in virtual classroom format or at our downtown Toronto location at 18 King Street East, Suite 1400, Toronto, Ontario, Canada (some in-person classroom courses may also be delivered at an alternate downtown Toronto location). Contact us at info@avantixlearning.ca if you’d like to arrange custom instructor-led virtual classroom or onsite training on a date that’s convenient for you.

Copyright 2023 Avantix® Learning

Microsoft, the Microsoft logo, Microsoft Office and related Microsoft applications and logos are registered trademarks of Microsoft Corporation in Canada, US and other countries. All other trademarks are the property of the registered owners.

Avantix Learning |18 King Street East, Suite 1400, Toronto, Ontario, Canada M5C 1C4 | Contact us at info@avantixlearning.ca

In another post (https://cybertext.wordpress.com/2018/07/22/word-wildcard-find-and-replace-for-numbers-inside-parentheses/), Thomas asked: “I have to find any number within a document and put it into brackets: 2 -> (2); 12 -> (12); 123 -> (123)”. But he wasn’t having any luck.

A standard Find can use ^# to find any single number (but not multiple numbers), but that command doesn’t work in a wildcard find and replace.

Here’s what I came up with instead; it assumes the numbers are surrounded by a space on both sides—it won’t find any numbers that include punctuation marks (e.g. 1,000,000), that start or finish with a punctuation mark (e.g. comma, period, parenthesis, semicolon, etc.), or those that are in a word (e.g. Model1345):

  1. Press Ctrl+H to open the Find and Replace dialog.
  2. Click More, then select the Use wildcards check box.
  3. In Find What, type: ( )(<[0-9]{1,}>)( ) (NOTE: there is a single space between the first set of parentheses and between the third set)
  4. In Replace With, type: 1(2)3
  5. Click Find Next, then click Replace once the first is found. Once you’re happy that it works, repeat until you’ve replaced them all.

What the find and replace ‘codes’ mean:

The three elements (each is enclosed in parentheses) of the Find are:

  1. ( ) — For the first and third elements, you type a set of parentheses, with a space inside the parens.
  2. (<[0-9]{1,}>) — The < and > represent the beginning and end of the ‘word’ respectively (in this case, the ‘word’ is a set of numbers with NO punctuation, e.g. 1, 12, 1234, 7896543); [0-9] represents any number from 0 to 9; {1,} says to look for one or more of the same (i.e. numbers) to any length immediately after that number, thus not limiting the find to only single digit numbers.

For the Replace:

  • 1 — Replaces the first element (the space) with itself
  • ( — Inserts an opening parens
  • 2 — Replaces the second element of the Find with what was in the Find (i.e. a number).
  • ) — Inserts a closing parens
  • 3 — Replace the third element (the space) with itself

Понравилась статья? Поделить с друзьями:
  • Word replace all text boxes
  • Word replace all pictures
  • Word replace all numbers
  • Word replace all mac
  • Word rhyming with yours