Microsoft Word Regex: Is there an "OR" operator such as |?

Viewed 881

Been poking around the internet but I can't seem to find one. This would be nice for cases such as finding and replacing numbers, i.e. one|1. I'd want to replace with one (1).

1 Answers

As Cindy pointed out, there is no "OR" operator using wildcards: https://answers.microsoft.com/en-us/msoffice/forum/all/or-operator-in-word-find/c7342d5e-9e08-43f2-96c5-347050601b01. That said, if you were to use Visual Basic to write a macro, you could "import" a RegEx object and use that, which SHOULD allow you to use an OR operator such as: "|" How to Use/Enable (RegExp object) Regular Expression using VBA (MACRO) in word. That's more difficult to build out than a simple Find and Replace. The operator in that case is, in fact "|", according to this document: https://www.udemy.com/blog/vba-regex/. But RegEx has many different implementations, or flavors, it's not a universal standard, even if many implementations share syntax. See this: https://en.wikipedia.org/wiki/Comparison_of_regular-expression_engines. This COULD have been different. And Word's wildcards, even if they're not traditional RegEx (I initially thought they were a flavor of RegEx but no longer do), could have supported an OR operator. They just don't as of this writing.

Related