我在尝试使用以下正则表达式时遇到问题:
string profileConfig = File.ReadAllText(str);
string startIndex = "user_pref(\"network.proxy.autoconfig_url\", \"";
string endIndex = "\"";
var regex = startIndex + "(.*)" + endIndex;
// Here we call Regex.Match.
Match match = Regex.Match(profileConfig,
regex,
RegexOptions.IgnoreCase);
// Here we check the Match instance.
if (match.Success)
{
// Finally, we get the Group value and display it.
string key = match.Groups[1].Value;
MessageBox.Show(key);
}
我得到错误:
Additional information: parsing "user_pref("network.proxy.autoconfig_url", "(.*)"" - Not enough )'s.
我的正则表达式是否存在某种形式的错误?
最佳答案
如果您打算匹配字符 (
字面意思是:
string startIndex = "user_pref\\(\"network.proxy.autoconfig_url\", \"";
关于c# - 正则表达式问题 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13991418/