ASP截取字符串的问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 17:36:25
asp中有个添加文章的功能,其中文章内容里面可以加图片,我是想用asp截取字符串的方式获得文章中图片的地址,请高手教教我
这是一个例子,

<P align=center><IMG src="/eWebEditor/webpic/2007102510833242.jpg" border=0></P>
<P>    材料: </P>

我只需要eWebEditor/webpic/2007102510833242.jpg这些代码.

用正则,很简单的

string text="<Palign=center>" +"<IMGsrc=\"/eWebEditor/webpic/2007102510833242.jpg\"border=0>"
+"</P><P> 材料: </P>";
Regex re = new Regex("/.*\\.jpg", RegexOptions.None);
MatchCollection mc = re.Matches(text);
foreach (Match ma in mc)
{ ... }

这样就OK了