Word: More find and replace with wildcards

April 20, 2012

I needed to make a global change to some text that the author had written incorrectly (i.e. not according to our house style guide).


They had written [Ref 1] for a reference instead of our style of [Ref. 1], which not only has a full stop (period) after the f but also uses a non-breaking space to separate the full stop and the following numeral. All the numbers were different. Some were a single number, while those from References 10 and higher were two-digit numbers. There were a LOT of references like this in the document.

So I used my knowledge of find and replace wildcards to globally make the change in just a few seconds.


This solution works in Word 2003, Word 2007, and Word 2010.

  1. In the Word document where you want to make this change, press Ctrl+H to open the Find and Replace dialog box; the Replace tab should be in focus.
  2. In the Find what field, type: (Ref)( )([0-9])
    Note: There is only ONE space in this string — it’s between the two parentheses that don’t appear to enclose anything. The 0-9 bit is a zero, not an ‘o’ for orange.
  3. In the Replace with field, type: \1.^s\3
    Note: There are NO spaces in this string and the s must be in lower case. Don’t forget the full stop!
  4. Click the More button.
  5. Select the Use wildcards check box.
  6. Click Find Next then click Replace to test that it works fine. If so, click Replace All.

Explanation for how this works:

  • (Ref) looks for the string of letters: Ref
  • ( ) looks for a space immediately after Ref (i.e. no punctuation)
  • ([0-9]) looks for any number that follows immediately after Ref and its following space. The square brackets indicate a range — in this case any number from 0 to 9 will be found. It doesn’t matter whether the numbers are one or two-digit numbers — the critical thing the find/replace is looking for is any numeral after Ref<space>.
  • \1 replaces the first part of the Find string with itself (in other words, Ref gets replaced with Ref)
  • .^s replaces the second part of the Find string (the space) with a full stop followed immediately by a non-breaking space. For a non-breaking space, you MUST use a lower case s and precede it with the ^ (Shift+6). Note: If you just want an ordinary space — not a non-breaking one — then use \2 instead of .^s.
  • \3 replaces the third part of the Find string with itself (in other words, the number found gets replaced with the same number).


  1. Find & Replace and Highlight many words & cells in MS EXCEL in Multiple Excel Worksheets & Files (xls, xlsx) using a software


  2. Great with single numbers but am obviously doing something wrong since it only finds the first digit of, for example, 14. I am changing Mar 24 to 24 Mar (etc etc) but the replace button will give me 2 Mar4 since it only finds the 2 of 24. Any suggestions??

  3. Hi ianbirds

    After a lot of fiddling around, I think I have the answer:
    * Find What: ([0-9]*)( )([A-z]{3,10})
    * Replace with: \3\2\1

    * In Find What, the first group looks for numbers [0-9] of any length (*). The second group looks for a single space. And the third group looks for 3 to 10 letter words of any case.
    * In Replace With, you rearrange the elements so that the word is listed first, followed by the space, followed by the number(s).

    Do NOT do this as a ‘replace all’ as you could replace some things you didn’t want to replace. Instead, click Find Next, check the found string, then click Replace if the string is a date/month string. Repeat.


  4. I have devised a F&R with wildcards to find all unspaced initials and change to spaced initials, thus:
    Find: ()(.)()(.)
    Replace: \1\2 \3\4
    (note there is a space after the 4)

    But I’m struggling with the vice-versa; I tried the following, but it doesn’t seem to work:
    Find: ()(.)( )()(.)( )
    Replace: \1\2\4\5

    Any suggestions??

  5. Hi Carol

    If I was trying to find Brown, AB, Brown CD, Brown, EF etc. and replace joined initials with a space, I’d do this:
    Find: ([A-Z])([A-Z])
    Replace with: \1 \2 (there’s a space between \1 and \2)

    If I was trying to find Brown, AB, Brown CD, Brown, EF etc. and replace joined initials with a space and a period, I’d do this:
    Find: ([A-Z])([A-Z])
    Replace with: \1. \2. (there’s a space between the first period and \2 and a period after \2)

    If I was trying to find Brown, A. B., Brown C. D., Brown, E. F. etc. and replace spaced initials with nothing, I’d do this:
    Find: ([A-Z])(.)( )([A-Z])(.)
    Replace with: \1\2\4\5 (there are NO spaces between these elements)

    Finally, if I was trying to find Brown, A. B., Brown C. D., Brown, E. F. etc. and replace spaced initials and periods with nothing (i.e. join them back up again), I’d do this:
    Find: ([A-Z])(.)( )([A-Z])(.)
    Replace with: \1\4 (there are NO spaces between these elements)

    Hope this helps


  6. It did help, Rhonda, because it worked!! Thank you so much. I’ve seen you on the LinkedIn editing forums – might be worth putting this on there??

  7. Hi Carol

    Feel free to mention it there. I’m on LinkedIn but not on any editing forums as far as I am aware.


  8. I would like to insert “> seq” in front of every number. Please hepl me
    I did try with:
    – In Find: ([0-9]*)
    – Replace with: (> seq)\([0-9]*)
    but not work
    Many thanks

  9. Hi Chi

    I’m away at the moment and have no access to Word, but I think what you need to type in the Replace field is > seq\1


  10. Hi Rhonda,
    Another ‘wildcard that won’t work’!
    I’m copy-editing a book with LOTS of unspaced ellipses and I’m trying to insert a space before all the ellipses . So I tried:

    Find: [A-z](…)
    Replace: \1 \2

    This didn’t work, and I tried different variants, with no success. Then – because I’m working with Track Changes – I selected a sample of the text and pasted it into a new document . . . and it WORKED! So I feel pretty confident the ‘formula’ is correct.

    I’ve tried switching off Track Changes in the main document – still doesn’t work
    Any suggestions?
    Thanks (again),

  11. Hi Carol

    Two things:
    * The [A-z] should be enclosed in parentheses as well — i.e. ([A-z])
    * When you type three consecutive periods in Word, Microsoft automatically turns it into an ellipsis, which is NOT the same as three periods! So make sure you COPY an ellipsis from the document and paste it into the Find field, enclosing it in parentheses too. Don’t type (…) — Word won’t find it.


  12. I can’t get this to work. I have “RAI 999” and I want to change it to change the space to a non-breaking space. I tired:
    find: (RAI)( )([0-9])
    repl: \1^s\3

    but the result comes out with RAI9 99, where the space is indeed non-breaking, but in the wrong location. I tried this is Word 2003 and Word 365. Both fail in the same way.

    If I repl with \1\2\3 I get RAI 999, so I know that the parsing is working correctly. WHy is the non-breaking space always at the end, not = matter how many variations I try?

  13. Hi Moto

    I just tried this in Word 2010 and it worked fine, so I’m not sure why it’s not working for you. I assume you have ‘Use Wildcards’ turned on, otherwise you’d get a different result altogether. And that there’s a space between the middle set of parentheses.

    Other things you can try:
    * Don’t use wildcards at all, just an ordinary find and replace — Find: RAI 999; Replace with: RAI^s999
    * Use wildcards: Find: (RAI)( )(9) (there’s a space between the middle parens); Replace with \1^s\3


  14. I just don’t get it. Yesterday it doesn’t work and today it does. Something in this 200 page file with track changes and gobs of comments must be just different enough today. Thanks.

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: