问题:http://community.csdn.net/Expert/topic/4706/4706491.xml?temp=6.908596E-03
在FreeTexBox中的所以html内容中找到图片html语言(<IMG height=550 src="http://localhost:2045/glietnet/image/news/news20060414105529.jpg" width=412 border=0>)或这句语言中的图片名字(news20060414105529.jpg)?
如果可以的话能否把这句图片html替换成<A href="image/news/news20060414105529.jpg"><IMG _fcksavedurl=""image/news/news20060414105529.jpg"><IMG" height=550 src="http://localhost:2045/glietnet/image/news/news20060414105529.jpg" width=412 border=0></A>
主要是提取http://localhost:2045/glietnet/image/news/news20060414105529.jpg中的文件名
实现方法如下:
string temp="http://localhost:2045/glietnet/image/news/news20060414105529.jpg";
temp=Regex.Match(temp,"[^/]//w*//.//w*",RegexOptions.IgnoreCase).ToString();
Response.Write("<script>alert('"+temp+"')</script>");
完整的实现替换如下:
string temp="http://localhost:2045/glietnet/image/news/news20060414105529.jpg";
string temp1="<IMG height=550 src=http://localhost:2045/glietnet/image/news/news20060414105529.jpg width=412 border=0>";
temp=Regex.Match(temp,"[^/]//w*//.//w*",RegexOptions.IgnoreCase).ToString();
temp1=Regex.Replace(temp1,@"<img .*>",@"<a href=image//news//"+temp+">"+temp1+"</a>",RegexOptions.IgnoreCase);
Response.Write("<script>alert('"+temp1+"')</script>");