The main use of the matching text:
XmlNode channles = root.FirstChild;
Regex r;
Match m;
r = new Regex( " href\\s*=\\s*(?:\ " ( ?< 1 > [ ^ \ " ]*)\ " | ( ?< 1 > \\S + ))\\s + \\S + \\s + title\\s *= \\s * ( ? :\ " (?<2>[^\ " ] * )\ " |(?<2>\\S+)) " ,RegexOptions.IgnoreCase | RegexOptions.Compiled);
for (m = r.Match(str); m.Success; m = m.NextMatch())
{// rst+="link=" + m.Groups[1] + "\ntitle=" + m.Groups[2]+"\n"; XmlElement oitem=xml.CreateElement("item"); XmlElement o=xml.CreateElement("title"); o.InnerText=m.Groups[2].Value; oitem.AppendChild(o); O
=xml.CreateElement("link");
o.InnerText=m.Groups[1].Value;
oitem.AppendChild(o);
channles.AppendChild(oitem);
}
Regular expression parsing the case:
. 1, the href = \\ \\ S * S *
matching the href, behind which there is no space = both, there may be several spaces.
2, (:?? \ " ? (<1> [^ \"] *) \ "| (<1> \\ S +))
removal of data 1, Link i.e., there are no marks on both sides thereof.
3 , \\ s + \\ S + \\ s +
match at least one blank each, followed by at least one non-space, each followed by at least one empty.
in fact, the match is target = _blank
We are continuing to make.
Found that regular expression too strong, simply SQL text processing, stronger than SQL!
Now I feel, I do not know that they are learning in order to achieve h2R service Regex, or to learn Regex and take h2R service to do the exercises.
They are very good.
Reproduced in: https: //www.cnblogs.com/civ3/archive/2005/10/16/256119.html