Regex 表达式有问题,C# 语句中的 "not enough )'s"
Having issues with Regex expression, "not enough )'s" in C# statement
我有这个正则表达式,它来自第三方。当我使用它时,出现 "not a enough )'s" 错误。正则表达式不是我的强项,虽然我看不出有什么明显的错误。
代码:
StringCollection sc = new StringCollection();
// Issue with following line
sc.Add(@"<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>");
foreach (string s in sc)
{
html = Regex.Replace(html, s, "", RegexOptions.IgnoreCase);
}
return html;
错误:
parsing "<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>" - Not enough )'s.
想法?
<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>
您正在开始第二个字符,其中一个(和另一个)在字符 class 中。
尝试:
<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>
我逃过了第一个[
我有这个正则表达式,它来自第三方。当我使用它时,出现 "not a enough )'s" 错误。正则表达式不是我的强项,虽然我看不出有什么明显的错误。
代码:
StringCollection sc = new StringCollection();
// Issue with following line
sc.Add(@"<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>");
foreach (string s in sc)
{
html = Regex.Replace(html, s, "", RegexOptions.IgnoreCase);
}
return html;
错误:
parsing "<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>" - Not enough )'s.
想法?
<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|![)[^>]*?>
您正在开始第二个字符,其中一个(和另一个)在字符 class 中。 尝试:
<(meta|link|/?o:|/?style|/?div|/?std|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>
我逃过了第一个[