你可以使用正则表达式获得:
Regex regex = new Regex("<img.*src\\s*=\\s*(?:\"(?<1>[^\"]*)\".*|(?<1>\\S+))",RegexOptions.IgnoreCase|RegexOptions.Compiled);
Regex regex = new Regex("<img.*src\\s*=\\s*(?:\"(?<1>[^\"]*)\".*|(?<1>\\S+))",RegexOptions.IgnoreCase|RegexOptions.Compiled);
看了很长时间,可是还是没弄明白,正则表达式看来是一门很深的学问啊,谢谢孟老大。@qiuji(忆秋季)
这个正则表达式怎么用啊?
比如 string s="<p><img src='beauty.jpg'>天使</p>";
Regex regex = new Regex("<img.*src\\s*=\\s*(?:\"(?<1>[^\"]*)\".*|(?<1>\\S+))",RegexOptions.IgnoreCase|RegexOptions.Compiled);
regex.Replace(s,"")
是不是就行了?
reg.Replace(s,"$1");