易截截图软件、单文件、免安装、纯绿色、仅160KB

Java URL正则表达式

 网上转贴的Java正则很让人失望,一篇JavaScript正则集录被很多不负责任的人转来转去,并打上Java正则的标题,汗,真是烂人一堆。
// url正则
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpressionTest {

public static void main(String[] args) {

Pattern p = Pattern.compile("^(http|www|ftp|)?(://)?(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*((:\\d+)?)(/(\\w+(-\\w+)*))*(\\.?(\\w)*)(\\?)?(((\\w*%)*(\\w*\\?)*(\\w*:)*(\\w*\\+)*(\\w*\\.)*(\\w*&)*(\\w*-)*(\\w*=)*(\\w*%)*(\\w*\\?)*(\\w*:)*(\\w*\\+)*(\\w*\\.)*(\\w*&)*(\\w*-)*(\\w*=)*)*(\\w*)*)$",Pattern.CASE_INSENSITIVE );
Matcher m = p.matcher("http://www.qqgb.com/Program/Java/JavaFAQ/JavaJ2SE/Program_146959.html");

if(m.find()){
System.out.println(m.group());
}

m = p.matcher("http://baike.baidu.com/view/230199.htm?fr=ala0_1");

if(m.find()){
System.out.println(m.group());
}

m = p.matcher("http://www.google.cn/gwt/x?u=http%3A%2F%2Fanotherbug.blog.chinajavaworld.com%2Fentry%2F4550%2F0%2F&btnGo=Go&source=wax&ie=UTF-8&oe=UTF-8");

if(m.find()){
System.out.println(m.group());
}

m = p.matcher("http://zh.wikipedia.org:80/wiki/Special:Search?search=tielu&go=Go");

if(m.find()){
System.out.println(m.group());
}

}
}
运行结果:
http://www.qqgb.com/Program/Java/JavaFAQ/JavaJ2SE/Program_146959.html
http://baike.baidu.com/view/230199.htm?fr=ala0_1
http://www.google.cn/gwt/x?u=http%3A%2F%2Fanotherbug.blog.chinajavaworld.com%2Fentry%2F4550%2F0%2F&btnGo=Go&source=wax&ie=UTF-8&oe=UTF-8
http://zh.wikipedia.org:80/wiki/Special:Search?search=tielu&go=Go
说明这几种类型的都可以识别。 
      //其他Java正则【转自itpub】 
      01、"^\\d+$"  //非负整数(正整数 + 0)
  02、"^[0-9]*[1-9][0-9]*$"  //


相关文档:

JAVA培训题库 Servlet

1.Servlet程序的入口点是:( )
A  init() 
B  main() 
C  service() 
D  doGet()
参考答案:A
2. Severlet中,HttpSeverletResponse的什么方法用来把一个HTTP请求重定向到另外的URL?( )
A  sendURL()
B  redirectURL()
C  sendRedirect()
D ......

Using Google is AJAX Search API with Java ...

http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php
I was rather depressed over a year ago when Google deprecated their SOAP Search API with their AJAX Search API. Essentially Google was saying that they didn want anyone programmatically accessing Google search ......

JAVA 培训题库 Spring

一、Spring基础知识及IOC_选择题
1. 下面关于spring描述错误的是:( )
A  Spring支持可插入的事务管理器,使事务划分更轻松,同时无需处理底层的问题。
B  Spring事务管理的通用抽象层还包括JTA策略和一个JDBC DataSource。
C  与JTA或EJB CMT一样,Spring的事务支持依赖于Java EE环境。
D  Spr ......

java(Web)中相对路径,绝对路径问题总结

1.基本概念的理解
  绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:\xyz\test.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个
URL绝对路径。
  相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号