正则获取图片路径
protected StringBuilder sb = new StringBuilder(); protected void Page_Load(object sender, EventArgs e) { string str = QConnectSDK.CustomWebRequest.getResponse("/", QConnectSDK.Method.GET, null); Regex reg = new Regex("<img([^\\/>src]+)src=\"([^\"]+)\"([^\\/]*)\\/?>"); MatchCollection mats = reg.Matches(str); Regex reg1 = null; string aa; foreach (Match mat in mats) { aa = mat.Value; reg1 = new Regex("src=\"([^\"]+)\""); sb.AppendFormat("<img src=\"/images/loading.gif\" orgsrc=\"http://www.xiaoyu365.com{0}\" />", reg1.Match(aa).Groups[1]); } }
<img([^\/>src]+)src="([^"]+)"([^\/]*)\/?>