0

I want to only match wildcards of a certain length or less using Microsoft Word's Advanced Find and Replace. I've tried using {n,m} following ? or * characters but it doesn't work for me, as seen in the example below (click to see detail). Note: the grayed numbers would be replaced by random characters in a real use case:

enter image description here

My question is just like this one, except that I want to use Microsoft Word's Advanced Find and Replace because of its ability to include formatting in the find/replace.

Tony M
  • 1,564
  • 1
  • 11
  • 30
  • This is an end-user question, not a programming one. As such it is off-topic for StackOverflow and should be asked in an appropriate end-user forum (e.g. MS Answers). – macropod Jun 22 '20 at 08:27
  • I will take your advice. However, many consider regex to be in the programming category and there are a large number of [regex]-tagged questions on StackOverflow with thousands of votes. I would be interested if you feel those qualify? I agree that MS Word regex is not at the same level as others, but it also has some features others do not, such as the formatting I mentioned. – Tony M Jun 22 '20 at 09:34
  • Word's wildcards and RegEx are not the same. Wildcards can be used without programming, RegEx cannot. There is no indication of any programming in your question. – macropod Jun 22 '20 at 11:35

1 Answers1

0

After some months, I found an answer to my own question:

Find what: (FIND[0-9]{2,4}ME)
Options: Use Wildcards
Replace with: \1
Format: Font color [as desired]

Of course, the original question was not of interest in itself, but constructed to illustrate. For a realistic example, the key is knowing how to use square brackets with a wildcard search; they substitute for the ? wildcard character to a large extent, but from this site I learned that the order in which you place characters within the brackets is important:

You can use any character or series of characters in a range [ ], including the space character. Characters are processed in alphanumeric order – lowest first. If you are uncertain which character is lower than another, look in the Insert + Symbol dialog

So, here's a more realistic example: I used [,.\?\!\"\'A-ÿ]{2,4} to find short strings containing all those punctuation characters as well as all letters A-z, plus the accented characters that come after z (that's why it ends with ÿ).

To figure out exactly what characters are included see the Advanced Symbol dialog below. That dialog also helps you determine the correct order to place characters within the brackets. The menu item to display the dialog for me was: Insert>Advanced Symbol...

enter image description here

Tony M
  • 1,564
  • 1
  • 11
  • 30