【发布时间】:2011-07-07 08:16:45
【问题描述】:
我正在尝试匹配不包含引号但它们可以包含转义引号的字符串。
当我说字符串时,我的意思是引号和其中的字符串。
我正在使用这个正则表达式,但它不起作用。
\"(?![^\\\\]\")\"
解决方案:
@"""[^""\\\r\n]*(?:\\.[^""\\\r\n]*)*"""
代码(c#)
MatchCollection matches = Regex.Matches(input,@"""[^""\\\r\n]*(?:\\.[^""\\\r\n]*)*""");
foreach (Match match in matches)
{
result += match.Index + " " + match.Value + System.Environment.NewLine ;
}
【问题讨论】:
标签: c# .net regex string quotation-marks