在这里,我在帖子中添加了一些额外的屏幕截图。使用帮助按钮上显示的文档。你会看到表格和我看到的。
文档
我们使用的正则表达式基于 PCRE - Perl Compatible Regular Expressions。完整的规范可以在这里找到:http://www.pcere.org 和 http://perldoc.perl.org/perlre.html
一些有用术语的总结:
元字符
\ Quote the next metacharacter
^ Match the beginning of the line
. Match any character (except newline)
$ Match the end of the line (or before newline at the end)
| Alternation
() Grouping
[] Character class
量词
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
字符类
\w Match a "word" character (alphanumeric plus mao}
\W Match a non-"word" character
\s Match a whitespace character
\S Match a non-whitespace character
\d Match a digit character
\D Match a non-digit character
捕获缓冲区
括号结构 (...) 创建捕获缓冲区。参考
在同一模式中,第一个使用 \1,第二个使用 \2,依此类推。在比赛之外使用“$”而不是“”。 \ 符号在匹配之外的某些情况下有效。有关详细信息,请参阅下面关于 \1 与 $1 的警告。
引用匹配的另一部分称为反向引用。
例子
用某些前缀字母 M N 或 E 替换故事以具有前缀“AA”:
`srcPattern "(M|N|E ) ([A-Za-z0-9\s]*)"`
`trgPattern "AA$2" `
`"N StoryWord1 StoryWord2" -> "AA StoryWord1 StoryWord2"`
`"E StoryWord1 StoryWord2" -> "AA StoryWord1 StoryWord2"`
`"M StoryWord1 StoryWord2" -> "AA StoryWord1 StoryWord2"`
"NoMatchWord StoryWord1 StoryWord2" -> "NoMatchWord StoryWord1 StoryWord2"(未找到匹配项,名称保持不变)