benshepherd

Regex help

Apr 14th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1.         static void Main(string[] args)
  2.         {
  3.             string input = "<div>This is a test</div><div class=\"something\">This is ANOTHER test</div>";
  4.             string pattern = "(<div.*>)(.*)(<\\/div>)";
  5.  
  6.             MatchCollection matches = Regex.Matches(input, pattern);
  7.             Console.WriteLine("Matches found: {0}", matches.Count);
  8.  
  9.             if (matches.Count > 0)
  10.                 foreach (Match m in matches)
  11.                     Console.WriteLine("Inner DIV: {0}", m.Groups[2]);
  12.  
  13.             Console.ReadLine();
  14.         }
  15.  
  16.  
  17. //http://www.reddit.com/r/csharp/comments/1ccjcs/getting_values_of_multiple_html_tags_regular/
Add Comment
Please, Sign In to add comment