c# - only get the src value -
i have in database field have tag. , lots of text..
for example:
hey there.. whats up? <img src="http://cdn.theatlantic.com/static/infocus/ngpc112812/s_n01_nursingm.jpg" alt="" /> .. , photo!..
i need between
src
i tried :
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; // url here // return replace value return @"<img src=""" + url + @""" border=""0"" />"; }, regexoptions.ignorecase); result = "<img src='" + result + "'/>"; return result; }
but i've got parsing error :
exception details: system.argumentexception: parsing "\([^]]+)\/>" - reference undefined group name img.
dont know though if code right path...
this question has been asked here.
string matchstring = regex.match(original_text, "<img.+?src=[\"'](.+?)[\"'].+?>", regexoptions.ignorecase).groups[1].value;
Comments
Post a Comment