我在数据库中有一个总是有标签的字段.还有很多文字..
例如:
Hey there.. whats up?
<img src="http://cdn.theatlantic.com/static/infocus/ngpc112812/s_n01_nursingm.jpg" alt="" />
.. and this is my photo!..
Run Code Online (Sandbox Code Playgroud)
我需要得到之间的东西
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;
}
Run Code Online (Sandbox Code Playgroud)
但我有一个解析错误:
异常详细信息:System.ArgumentException:解析"\([^]] +)\ />" - 对未定义组名img的引用.
不知道我的代码是否正确...
Atl*_*ybe 13
这个问题已在这里提出.
string matchString = Regex.Match(original_text, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13480 次 |
| 最近记录: |