只获取src值
我在数据库中有一个总是有标签的字段。 还有很多文字..
例如:
Hey there.. whats up? .. and this is my photo!..
我需要得到之间的东西
SRC
我试过了 :
public string LinkPicCorrect(string path) { //string input = "[img]http://imagesource.com[/img]"; string pattern = @"\([^\]]+)\\/>"; string result = Regex.Replace(path, pattern, m => { var url = m.Groups[1].Value; // do something with url here // return the replace value return @""; }, RegexOptions.IgnoreCase); result = ""; return result; }
但我有一个解析错误:
exception详细信息:System.ArgumentException:解析“\([^]] +)\ />” – 引用未定义的组名img。
不知道我的代码是否正确…
这个问题已在这里提出。
string matchString = Regex.Match(original_text, "", RegexOptions.IgnoreCase).Groups[1].Value;
你可以试试这个正则表达式模式: –
string pattern= Regex.Match(path, "", RegexOptions.IgnoreCase).Groups[1].Value;