[英]Regex match pattern up to a “.”
我正在尝试使用正则表达式将字符串匹配到句点。 例如我有这个字符串
Updated IVR Info response to :Answered but No Response. Locked for IVR processing.
Updated IVR Info response to :Yes. Locked for IVR processing.
Updated IVR Info response to :No. Locked for IVR processing.
我希望我的比赛集合包含3个字符串。
Answered but No Response
No
Yes
我试过了..
string pattern = "Updated IVR Info response to :.+?/.";
Regex r = new Regex(pattern);
var matches = r.Matches(item.Information);
我认为您正在转义'。 错误的方法:
"Updated IVR Info response to :.+?\\.";
要获取实际值,请使用以下组:
string pattern = "Updated IVR Info response to :(.+?\\.)";
Regex r = new Regex(pattern);
var values = r.Matches(item.Information).Cast<Match>().Select(m => m.Groups[1].Value);
输出:
已回答,但没有回应。
是。
没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.