Here is working php code
<?php
$str = '<users>
<user id="1" value1="afaaf" value2="racad" value3="xarcd">User1</user>
<user id="2" value1="fsvgvdsg" value2="wdafsc" value3="aefvbdfg">User2</user>
<user id="3" value1="chthb" value2="rtvfascf" value3="xasedfvg">User3</user>
</users>';
$out = '';
if(preg_match_all('|<user id="(.*)" value1="(.*)" value2="(.*)" value3="(.*)">(.*)</user>|',$str,$matches))
{
for($i=0;$i<count($matches[1]);$i++)
$out .= $matches[1][$i].'|'.$matches[2][$i].'|'.$matches[3][$i].'|'.$matches[4][$i].'|'.$matches[5][$i]."
";
echo $out;
}
?>
This is what I get
1|afaaf|racad|xarcd|User1
2|fsvgvdsg|wdafsc|aefvbdfg|User2
3|chthb|rtvfascf|xasedfvg|User3
C# code
string patt = "<user id=\"(.*)\" value1=\"(.*)\" value2=\"(.*)\" value3=\"(.*)\">(.*)</user>";
string str = "<users><user id=\"1\" value1=\"afaaf\" value2=\"racad\" value3=\"xarcd\">User1</user><user id=\"2\" value1=\"fsvgvdsg\" value2=\"wdafsc\" value3=\"aefvbdfg\">User2</user><user id=\"3\" value1=\"chthb\" value2=\"rtvfascf\" value3=\"xasedfvg\">User3</user></users>";
MatchCollection mc;
Regex r = new Regex(patt);
mc = r.Matches(str);
for (int i = 0; i < mc.Count; i++)
textBox1.Text += mc[i].Value + "
";
and I get
<user id=\"1\" value1=\"afaaf\" value2=\"racad\" value3=\"xarcd\">User1</user><user id=\"2\" value1=\"fsvgvdsg\" value2=\"wdafsc\" value3=\"aefvbdfg\">User2</user><user id=\"3\" value1=\"chthb\" value2=\"rtvfascf\" value3=\"xasedfvg\">User3</user>
You can see that string what i get from c# code isn't even close to my php result.
How to get result like from my php code?
Hope you understand what is my problem here.
Thanks