public static Tag[] ExtractTags(ref string content, params string[] tagnames)
{
List<Tag> tags = new List<Tag> ();
foreach (string tagname in tagnames) {
MatchCollection matches = Regex.Matches (content, @"([<]" + tagname + @" )([^>]*?)( /[>])");
foreach (Match match in matches) {
string tagcontent = match.Groups [1].Value + match.Groups [2].Value + match.Groups [3].Value;
content.Replace (tagcontent, "");
tags.Add (new Tag (tagname: tagname, content: tagcontent));
}
matches = Regex.Matches (content, @"([<]" + tagname + @"[ >])([^>]*?" + "[\"=]" + @">.*?)([<]/" + tagname + @"[>])");
Console.WriteLine ("match: " + @"([<]" + tagname + @"[ >])(.*?)([<]/" + tagname + @"[>])");
Console.WriteLine ("matches: " + matches.Count);
foreach (Match match in matches) {
string tagcontent = match.Groups [1].Value + match.Groups [2].Value + match.Groups [3].Value;
content.Replace (tagcontent, "");
tags.Add (new Tag (tagname: tagname, content: tagcontent));
}
}
return tags.ToArray ();
}