Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 正则表达式不';I don’我找不到一个匹配的模式_Html_.net_Regex - Fatal编程技术网

Html 正则表达式不';I don’我找不到一个匹配的模式

Html 正则表达式不';I don’我找不到一个匹配的模式,html,.net,regex,Html,.net,Regex,在一个C#项目中,正则表达式对我来说表现得很奇怪 我有这个方法: string RegTest() { string HTML = "<input type=\"hidden\" name=\"authenticity_token\" value=\"d27956cca6b75db4d8dd502d0569dd246455131c\">"; Regex AuthRegex = new Regex(@"name=""authenticity_to

在一个C#项目中,正则表达式对我来说表现得很奇怪

我有这个方法:

string RegTest()
    {
        string HTML = "<input type=\"hidden\" name=\"authenticity_token\" value=\"d27956cca6b75db4d8dd502d0569dd246455131c\">";
        Regex AuthRegex = new Regex(@"name=""authenticity_token"" value=""([A-Ba-b0-9/-]+)""");
        string Auth = AuthRegex.Match(HTML).Value;
        return Auth;
    }
string RegTest()
{
字符串HTML=“”;
Regex AuthRegex=new Regex(@“name=”“authenticity_token”“value=”“([A-Ba-b0-9/-]+)”);
字符串Auth=AuthRegex.Match(HTML).Value;
返回Auth;
}
出于一个我完全不理解的原因,正则表达式找不到与此模式匹配的任何东西。它只返回

如何解决此问题?

问题是:

[A-Ba-b0-9/-]+
字符范围(
x-y
)的基本功能是获取一组介于两者之间的所有字符。换句话说,
a-b
=介于
a
b
之间的所有字母,也就是仅
a
b
。但是,

d27956cca6b75db4d8dd502d0569dd246455131c
看起来像个妖术。因此,您应该使用

[A-Fa-f0-9-]+

相反。

@ndn我认为通过使用
@
我不需要逃避它。什么是正确的方式来摆脱它的模式?好的,非常感谢!现在我也注意到我写了
A-B
,而不是像平时那样写
A-Z
-_-