如何从字符串中获取url并将其存储到另一个字符串中“
问题描述:
我有一个如下字符串
I have a string like below
obj.HtmlNote = @"This is my site that we have to maintain:<a href='http://www.myapplation.html'>Click here</a>";
ViewBag.message = Session["objstr"] + obj.HtmlNote;
这里我想将网址拆分并存储到另一个字符串中,如下所示。
string emailbody =http://www.myapplation.html;
你能帮忙帮忙从这个striing获取url吗?
here i want to split the url and store into another string like below.
string emailbody="http://www.myapplation.html";
Could you please help how get url from that striing?
答
使用正则表达式:
Use a regex:
(?<=<a href=').*(?='>)
应该这样做。