我正在尝试匹配不包含引号但它们可以包含转义引号的字符串。
当我说字符串时,我的意思是引号和其中的字符串。
我正在使用这个正则表达式,但它不起作用。
\"(?![^\\\\]\")\"
解决方案:
@"""[^""\\\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 ;
}