站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2SE 专题jsp 如何,用正则表达式。获取-lt;img src=0.gif-gt;中的0.gif??????????

jsp 如何,用正则表达式。获取-lt;img src=0.gif-gt;中的0.gif??????????

摘要: jsp 如何,用正则表达式。获取-lt;img src=0.gif-gt;中的0.gif??????????


大家好。很感谢进来的人
在保存的时候。我用web在线编辑器.保存在字段content里面的是html代码。
我想。用正则来。。获取到content 里面的。。第一张图片。这在新闻发布系统中。经常用到
如String content=-#34;-#60;html-#62;-#60;img src=0.gif-#62;-#60;/html-#62;-#34;
我如何。。获取0.gif呢?


没把问题说清楚。


import java.util.regex.*;
class Test {
public static void main(String[] args) {
String content=-#34;-#60;html-#62;-#60;img src=0.gif-#62;-#60;/html-#62;-#34;;
Matcher m = Pattern.compile(-#34;-#60;img[//s]+[^-#62;]*src=([-#39;/-#34;]?)([//w//.]+)//1[^-#62;]*-#62;-#34;).matcher(content);
if(m.find()){
System.out.println(m.group(2));
}
}
}



[//s]+可以换成[//s],更好一点


谢谢,,我试试看。


我是写在jsp的呀。


非常感谢。


↑返回目录
前一篇: 一个非常低级的问题
后一篇: 验证money类型的正则该怎么写?