benshepherd icon

Regex help

benshepherd | PRO | 04/14/13 09:35:05 PM UTC | 0 ⭐ | 330 👁️ | Never ⏰ | []
C# |

640 B

|

None

|

0 👍

/

0 👎

        static void Main(string[] args)
        {
            string input = "<div>This is a test</div><div class=\"something\">This is ANOTHER test</div>";
            string pattern = "(<div.*>)(.*)(<\\/div>)";
 
            MatchCollection matches = Regex.Matches(input, pattern);
            Console.WriteLine("Matches found: {0}", matches.Count);
 
            if (matches.Count > 0)
                foreach (Match m in matches)
                    Console.WriteLine("Inner DIV: {0}", m.Groups[2]);
 
            Console.ReadLine();
        }
 
 
//http://www.reddit.com/r/csharp/comments/1ccjcs/getting_values_of_multiple_html_tags_regular/

Comments