Microsoft Word 正则表达式:是否有 "OR" 运算符,例如 |?
Microsoft Word Regex: Is there an "OR" operator such as |?
一直在互联网上搜索,但似乎找不到。这对于查找和替换数字(即 one|1)等情况非常有用。我想替换为一 (1) 个。
正如 Cindy 所指出的,没有 "OR" 运算符使用通配符: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。这可能是不同的。 Word 的通配符,即使它们不是传统的 RegEx(我最初认为它们是 RegEx 的一种风格,但现在不再是),也可以支持 OR 运算符。在撰写本文时,他们只是不会。
一直在互联网上搜索,但似乎找不到。这对于查找和替换数字(即 one|1)等情况非常有用。我想替换为一 (1) 个。
正如 Cindy 所指出的,没有 "OR" 运算符使用通配符: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。这可能是不同的。 Word 的通配符,即使它们不是传统的 RegEx(我最初认为它们是 RegEx 的一种风格,但现在不再是),也可以支持 OR 运算符。在撰写本文时,他们只是不会。