首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

这个取网页中图片的正则表达式为什么会报错?解决办法

2011-12-30 
这个取网页中图片的正则表达式为什么会报错?取一个在线编辑器送来的html内容中的图片地址,正则如下,通过正

这个取网页中图片的正则表达式为什么会报错?
取一个在线编辑器送来的html内容中的图片地址,正则如下,通过正则检测工具检查,可以取出图片的地址,但在Resin中却报错,百思不得其解,望明白的指点一下。
String   content   =   request.getParameter( "content ");
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",       Pattern.CASE_INSENSITIVE     );      
Matcher   mat   =pat.matcher(content);
while(mat.find())
{
      out.print(mat.group()+ " <br> ");
      }
报错代码如下:
500   Servlet   Exception
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                          ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                              ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                                    ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                                          ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                                                                                                ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",


Pattern.CASE_INSENSITIVE     );      
                                                                                                                                                      ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                                                                                                              ^
/TestFCKeditor/show.jsp:35:   ^?IW&
Pattern   pat   =   Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ",
Pattern.CASE_INSENSITIVE     );      
                                                                                                                                                                      ^
8   ?


--------------------------------------------
Resin-3.0.13   (built   Fri,   06   May   2005   10:06:25   PDT)

[解决办法]
Pattern pat = Pattern.compile( "http:\/\/(\w+\.)+(net|com|cn|org|cc|tv)(\S*\/)(\S)+\.(gif|jpg|png|bmp) ", Pattern.CASE_INSENSITIVE );


代码放在一行输入或者增加上续行符号

热点排行