(...) (表达式分组)

Top  Previous  Next

 

和在算术中一样,在正则表达式中括号也用于分组。它们经常和 '|' 或 功能一起使用,将多个选择分为一组。

 

例如:

 

表达式 '12 Mar(ch)? 2000' 将找到字符串  '12 March 2000' 和 '12 Mar 2000'。注意这里使用了 '?' 出现0次或多次单字符

 

如果您将表达式 '^myfile\.(txt|doc)$' 作为文件名输入,那么它将找到任何名为 'myfile.txt' 或 'myfile.doc' 的文件。注意这里使用了 '^' 字符串的开始 字符,将 '.' in '.txt' 作为字面含义对待的 '\' 转义符 ,还有 '$' 字符串的结束 字符。


Copyright © 2021 Mythicsoft Ltd. All rights reserved.
Help file version: 9.0

PDF and CHM versions of this help file are available here:
http://mythicsoft.com/filelocatorpro/help