使用MS Word中的RegEx匹配单词的变量和错误拼写

时间:2016-10-24 09:06:36

标签: javascript regex

我正在尝试使用Microsft Word查找和替换功能来捕获单词的变体。这是一个可搜索的片段:

       There are going to be 3 instances of the word successful for the purpose of Regex matching. Here is the second sucesfull and here is another succesfull , both spelt incorrectly.

这是我在“查找和替换”中使用的Regex表达式选择了“使用通配符”(我也尝试过用括号替换大括号而没有欢乐)

≤([SS] UC [1,] ES [1,] FUL [1,2])>

2 个答案:

答案 0 :(得分:0)

((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Level = Level.Debug;
((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).RaiseConfigurationChanged(EventArgs.Empty);

将[]替换为{},它应该可以正常工作。花括号指定您希望重复字符的次数。方括号用于指定可接受的字符。

因此,当前正则表达式将匹配以下内容。

  • succcccesssfulll
  • sucesful
  • 成功
  • Successsssfull

等等。

我认为这更清洁,更容易打字。

BigGray% g++ t.cpp -o t
BigGray% ./t
Enter operator either + or - or * or /+
Enter two operands: 1 3
4%                                                                                                                                                                                                    BigGray% g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
BigGray% uname -a
Darwin BigGray.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
BigGray%

“+”计算一个或多个字符的出现次数。

答案 1 :(得分:0)

您想要的搜索字符串是:

<[sS]uc@es@ful@>

这会搜索以<>开头并包含一个或多个(s符号的单词(S@符号) )csl