Search code examples
c#regexxpathcharactervar

regex variable from script 32/34 characters


from the following code I am trying to get the data from the script variable. I'm interested in the text between ""

var code = "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 is correct? what am I doing wrong?


Solution

  • Your Regex string can try to use [0-9a-zA-Z]{32,34} instead of .[0-9a-zA-Z]{34}$.

    The . could be removed.

    regex online