Click here to Skip to main content
11,928,786 members (56,146 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#5
I have an html o/ i need to find a span tag and ..i need to get child elements in span tag...
here is my code
   List<string> pages = new List<string>();
            String regex = "<span class=\"prime-message\"> $1 </span>";
            MatchCollection th = Regex.Matches(data, regex, RegexOptions.Singleline);
            foreach (Match i in th)
		        string target=i.Groups[0].Value;

here i could not getting span elements tags in side of "i" in foreach loop...and also i was not getting any elements in "th" coud i achieve this...i just need to get spam tag in side of "i" in foreach loop....i wasso thankfull for any sugestions and advices...
Posted 22-Jul-14 1:21am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'd suggest to read this:[^]
If you want to proccess through several lines, use MultiLine option instead of SingleLine.

string to search within: "<span class="\"prime-message\""> $1 </span>" 
pattern =                "<span\b[^>]*>(.*?)</span>"
returned value:          $1

Tested via: RegexDesigner[^]
RaisKazi 22-Jul-14 11:04am
My 5.
Maciej Los 22-Jul-14 11:08am
Thank you ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 22 Jul 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100