在C#的以下字符串中,什么是匹配单词call或CALL的正则表达式?
NIFTY-CALL-1200-Aug11
NIFTY CALL 1200 Aug11
NIFTYCALL-CALL-1200-Aug11 //In this case second call word must be matched not NIFTYCALL.
NIFTYCALL CALL 1200 Aug11 //In this case second call word must be matched not NIFTYCALL.
CALLNIFTY CALL 1200 Aug11 //In this case second call word must be matched not CALLNIFTY.
CALLNIFTY CALL 1200 Aug11 //In this case second call word must be matched not CALLNIFTY.
CALLNIFTY Aug11 1200CALL //In this case last call word must be matched not CALLNIFTY.
CALLNIFTY 1200 Aug11CALL //In this case last call word must be matched not CALLNIFTY.发布于 2011-11-17 15:25:22
关于
Regex regexObj = new Regex(@"(?:\b|[0-9])(CALL)\b", RegexOptions.Singleline);CALL)查找字符串并将其放入匹配组
\b part再次检查单词边界。发布于 2011-11-17 15:25:30
它会是
Regex re = new Regex(@"(\d|\b)(CALL|call)(\d|\b)");发布于 2011-11-18 03:42:37
也可以使用
Regex re = new Regex(@"(\d|\b)(CALL)(\d|\b)",RegexOptions.IgnoreCase);而不是使用CALL|call。这样,您还可以匹配"CALl“或"cAll”。(当然,如果需要的话)。
https://stackoverflow.com/questions/8163405
复制相似问题