Find and Replace Using Wildcards

Anonymous
2024-10-16T22:18:17+00:00

I have a document with lots of references in it. The references look like this: [R1], [R2], . . . [R101], etc. I want those references to appear instead italicized and in red: [R1], [R2], . . . [R101]. Word will not accept searches with wildcards, e.g. [R^#^#]. Is there a way to do a search that will find the bracketed statements and both italicize and re-color them with whatever numerical characters are in them? I can always make the changes by hand, of course, but that's a bit kludgy.

Thanks.

Microsoft 365 and Office | Word | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Jay Freedman 205.9K Reputation points Volunteer Moderator
    2024-10-16T23:40:52+00:00

    In the Replace dialog, did you click the More button and check the box for "Use wildcards"? If you want to use a search expression like [R^#^#] then you should NOT check that box. Note that with non-wildcard expressions like this, you'll need to do three separate searches for references with one-, two-, or three-digit numbers.

    The Replace With expression should be ^& and then click the Format button, choose Font in the menu, and select Italic and the red color.

    What Word refers to as wildcards (Microsoft's modified version of regex search) does not recognize the caret codes such as ^#. The caret codes are only for non-wildcard searches.

    If you want to use wildcards, the search expression should be

    (\[R[0-9]{1,3}\])
    

    which will match the letter R followed by any one to three digits. Be careful to use the square brackets, curly brackets, parentheses, and backslashes in the proper places. For explanations, see https://www.gmayor.com/replace_using_wildcards.htm

    The parentheses around the expression allow you to use \1 as the "found text" in the Replace With box instead of ^&. The setting of font formatting is the same as above.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-10-18T03:06:21+00:00

    Jay,

    I'm very grateful for your response. I haven't yet had time to try it out, but I will tomorrow.

    If I get stuck (on account of being none too bright to begin with), may I follow up with you?

    Don

    0 comments No comments
  2. Jay Freedman 205.9K Reputation points Volunteer Moderator
    2024-10-18T11:33:48+00:00

    Please do ask any questions you have. I'm here every day.

    0 comments No comments
  3. Anonymous
    2024-10-18T14:10:23+00:00

    Jay,

    I am back, and I joyfully accuse you of being a genius. You've saved me many hours of tedious work and taught me something very important about Word. I had never known that ^& is the way to preserve the search-for characters intact even if they appear as ^#, and I assume that it works that way for the other characters that a caret precedes.

    0 comments No comments
  4. Jay Freedman 205.9K Reputation points Volunteer Moderator
    2024-10-18T15:26:39+00:00

    Helping Word users to learn about its abilities -- and its quirks and limitations -- is why I'm still here after 20 years.

    I'll recommend again that you visit Graham Mayor's page at

    https://www.gmayor.com/replace_using_wildcards.htm

    to learn about the caret-character expressions and the wildcard variations. Most of those expressions work only in one of the two types of search, and you need to know (or look up) which is which.

    0 comments No comments