code_junkie

Why does Regex.Match return only 1 result?

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Match m = Regex.Match(htmlSourceString, "href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\']");
  2.  
  3. if (m.Success)
  4. {
  5. Console.WriteLine("values = " + m);
  6. }
  7.  
  8. Match m = Regex.Match(htmlSourceString, "href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\']");
  9. Console.Write("values = ");
  10. while (m.Success)
  11. {
  12. Console.Write(m.Value);
  13. Console.Write(", "); // Delimiter
  14. m = m.NextMatch();
  15. }
  16. Console.WriteLine();
Add Comment
Please, Sign In to add comment