Click here to Skip to main content
13,090,672 members (42,930 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 0: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 |
Web03 | 2.8.170813.1 | Last Updated 22 Jul 2014
Copyright © CodeProject, 1999-2017
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