I have this problem with Regex in C#, where I can't return multiple matches in one array. I've tried using a loop to do it, but I feel there has to be a better way. In PHP, I usually just have to do:
<?php
$text = "www.test.com/?site=www.test2.com";
preg_match_all("#www.(.*?).com#", $text, $results);
print_r($results);
?>
Which will return:
Array
(
[0] => Array
(
[0] => www.test.com
[1] => www.test2.com
)
[1] => Array
(
[0] => test
[1] => test2
)
)
However, for some reason, my C# code only finds the first result (test). Here is my code:
string regex = "www.test.com/?site=www.test2.com";
Match match = Regex.Match(regex, @"www.(.*?).com");
MessageBox.Show(match.Groups[0].Value);