tylko uzyskaj wartość src
Mam w bazie danych pole, które zawsze będzie miało tag. a także mnóstwo tekstu ..
Na przykład:
Hey there.. whats up?
<img src="http://cdn.theatlantic.com/static/infocus/ngpc112812/s_n01_nursingm.jpg" alt="" />
.. and this is my photo!..
Muszę uzyskać TYLKO to, co między
src
Próbowałem :
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;
}
Ale mam błąd parsowania:
Szczegóły wyjątku: System.ArgumentException: parsowanie "([^]] +) />" - Odniesienie do niezdefiniowanej nazwy grupy img.
nie wiem, czy mój kod jest właściwą ścieżką ...