我正在尝试使用正则表达式将字符串匹配到句点。例如,我有这个字符串
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);
答案 0 :(得分:3)
答案 1 :(得分:2)
我认为你正在逃避''。'错误的方式:
"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);
输出:
回答但没有回应 是的。
否。