【发布时间】:2013-08-20 08:33:10
【问题描述】:
我在数据库中有一个总是有标签的字段。还有很多文字..
例如:
Hey there.. whats up?
<img src="http://cdn.theatlantic.com/static/infocus/ngpc112812/s_n01_nursingm.jpg" alt="" />
.. and this is my photo!..
我只需要得到 p>
src
我试过了:
public string LinkPicCorrect(string path)
{
//string input = "[img]http://imagesource.com[/img]";
string pattern = @"\<img>([^\]]+)\\/>";
string result = Regex.Replace(path, pattern, m =>
{
var url = m.Groups[1].Value;
// do something with url here
// return the replace value
return @"<img src=""" + url + @""" border=""0"" />";
},
RegexOptions.IgnoreCase);
result = "<img src='" + result + "'/>";
return result;
}
但是我有一个解析错误:
异常详情:System.ArgumentException: parsing "\([^]]+)\/>" - 引用未定义的组名 img。
不知道我的代码是否正确...
【问题讨论】: