Hack Forums
[C#] Regex Problem - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Regex Problem (/showthread.php?tid=5968329)



Regex Problem - HardStoN - May 9, 2019

Hi guys,
I built a regex
Code
<span dir=\"ltr\">([a-zA-Z0-9']+)</span>

that should give me the span's inside an html and i went to site called regex tester and it gave me 6 matches but when im
putting it in my c# code it gives me none

CODE C#:
Code
WebClient client = new WebClient();
            string html = client.DownloadString(@"My url");

            Regex r = new Regex("<span dir=\"ltr\">([a-zA-Z0-9']+)</span>");
          
            
                foreach (Match t in r.Matches(html))
                {
                    Console.WriteLine(t.ToString());
                  
                }

Thanks for all the help


RE: Regex Problem - HFDone - May 9, 2019

you add extra ' [a-zA-Z0-9']


RE: Regex Problem - HardStoN - May 9, 2019

(May 9, 2019 11:19 AM)HFDone Wrote:  you add extra ' [a-zA-Z0-9']

No i didnt i want to take the char ' as a possibilty


Never mind the problem was in the html string