【发布时间】:2014-04-22 02:34:00
【问题描述】:
正则表达式模式
patternMatch = "^(?i)/(A|B)?(?:/index.html|/|)"
输入字符串 -
inputString = "/_Test/C.asmx"
(Regex.IsMatch(inputString, patternMatch, RegexOptions.IgnoreCase)) 返回真,什么时候应该返回假。
现在,我知道双 '?'不需要在正则表达式模式中。但是,我只是想找出模式匹配失败的原因。
http://www.regexr.com/ 告诉我它应该返回 false。
【问题讨论】:
-
它匹配是因为 or:
|.. 也.. Regexr 匹配它。它匹配第一个正斜杠。 -
是的,正则表达式不匹配。它不应该。但是,在 .net Regex.IsMatch 中返回 true。
-
怎么来的或者:|是否干扰了模式匹配?