I have a sample string:
<num>1.</num> <Ref>véase anomalía de Ebstein</Ref> <num>2.</num> <Ref>-> vascularización</Ref>
I wish to make a comma seperated string with the values inside ref tags.
I have tried the following:
Regex r = new Regex('<ref>(?<match>.*?)</ref>'); Match m = r.Match(csv[4].ToLower()); if (m.Groups.Count > 0) { if (m.Groups['match'].Captures.Count > 0) { foreach (Capture c in m.Groups['match'].Captures) { child.InnerText += c.Value + ', '; } child.InnerText = child.InnerText.Substring(0, child.InnerText.Length - 2).Replace('-> ', ''); } }
But this only ever seems to find the value inside the first ref tag.
Where am I going wrong?
You want to be using Matches rather than match to get all matches that occur, something like: