来自脚本 32/34 个字符的正则表达式变量

regex variable from script 32/34 characters

从下面的代码中,我试图从脚本变量中获取数据。我对“”

之间的文字感兴趣

var 代码 = "a37965dcd8421328a767c697448ed735";

            XPathResult xpathResult = geckoWebBrowser1.Document.EvaluateXPath("/html/body/table[3]/tbody/tr[1]/td[2]/script");
        var foundNodes = xpathResult.GetNodes();
        foreach (var node in foundNodes)
        {
            var x = node.TextContent; // get text text contained by this node (including children)
            GeckoHtmlElement element = node as GeckoHtmlElement; //cast to access.. inner/outerHtml
            string inner = element.InnerHtml;
            string outer = element.OuterHtml;
            String pattent = ".[0-9a-zA-Z]{34}$.";
            Match match = Regex.Match(inner, pattent);

正则表达式正确吗?我做错了什么?

您的 Regex 字符串可以尝试使用 [0-9a-zA-Z]{32,34} 而不是 .[0-9a-zA-Z]{34}$.

可以删除 .

regex online

您的 Regex 规则可以这样尝试:

bool result = Regex.Match(inner, @"^[0-9a-zA-Z]{32,34}$").Success;
Console.WriteLine(result);

如果结果等于true,则匹配成功!