Java正则表达式(总结二)
本次主要以例子为主:
1.匹配图像 /**
* 匹配图象 <br>
* 格式: /相对路径/文件名.后缀 (后缀为gif,dmp,png)
* 匹配 : /forum/head_icon/admini2005111_ff.gif 或 admini2005111.dmp<br>
* 不匹配: c:/admins4512.gif
*/
public static final String icon_regexp = "^(/{0,1}\\w){1,}\\.(gif|dmp|png|jpg)$|^\\w{1,}\\.(gif|dmp|png|jpg)$";
2.匹配邮件
/**
* 匹配email地址 <br>
* 格式: XXX@XXX.XXX.XX
* 匹配 : foo@bar.com 或 foobar@foobar.com.au <br>
* 不匹配: foo@bar 或 $$$@bar.com
*/
public static final String email_regexp = "(?:\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3}$)";
3.匹配并提取URL
/**
* 匹配匹配并提取url <br>
* 格式: XXXX://XXX.XXX.XXX.XX/XXX.XXX?XXX=XXX
* 匹配 : http://www.suncer.com 或news://www<br>
* 提取(MatchResult matchResult=matcher.getMatch()): matchResult.group(0)=
* http://www.suncer.com:8080/index.html?login=true matchResult.group(1) =
* http matchResult.group(2) = www.suncer.com matchResult.group(3) = :8080
* matchResult.group(4) = /index.html?login=true
* 不匹配: c:\window
*/
public static final String url_regexp = "(\\w+)://([^/:]+)(:\\d*)?([^#\\s]*)";
4.匹配并提取http
/**
* 匹配并提取http <br>
* 格式: http://XXX.XXX.XXX.XX/XXX.XXX?XXX=XXX 或 ftp://XXX.XXX.XXX 或
* https://XXX
* 匹配 : http://www.suncer.com:8080/index.html?login=true<br>
* 提取(MatchResult matchResult=matcher.getMatch()): matchResult.group(0)=
* http://www.suncer.com:8080/index.html?login=true matchResult.group(1) =
* http matchResult.group(2) = www.suncer.com matchResult.group(3) = :8080
* matchResult.group(4) = /index.html?login=true
* 不匹配: news://www
*/
public static final String http_regexp = "(http|https|ftp)://([^/:]+)(:\\d*)?([^#\\s]*)";
5.匹配日期
/**
* 匹配日期 <br>
* 格式(首位不为0): XXXX-XX-XX 或 XXXX XX XX 或 XXXX-X-X <br>
* 范围:1900--2099 <br>
* 匹配 : 2
相关文档:
迅雷面试回来,用了整整一下午(不知道怎么说了,其中等待时间都快2小时了),自己感觉笔试和上机还可以,但技术面谈这一关答得不太好,现在再次感觉互联网公司与一般软件公司的区别了,其中一点就是互联网应用在性能上要求很高,谈了一个小时大部分题目感觉都在谈论性能问题,自己在方面一直是弱项,汗啊:(
仔细回忆了 ......
Java代码
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
......
package tf;
public class TestPack {
public static void main(String [] args)
{
try
{
IAnimal cAnimal = new bird();
cAnimal.shout();
IAnimal animal =(IAnimal)java.lang.Class ......
Today , i take the first lesson of java ,let me sum up the details:
firstly,about jdk and jre.jdk stands for java development kit,while jre represent java Runtime Environment. jdk is the key of Java. And,jvm(java virtual machine) is the key of jre.
then ,about the platform independence of java.Dur ......
本文对 Java Debug Interface(JDI)及其使用进行了介绍,并通过实现一个多线程分析器的示例应用,演示了如何利用 JDI 开发自己的多线程调试程序。该示例分析器在独立于目标程序的前提下,以单个线程流为单位,帮助追踪记录多线程的执行过程信息。
多线程环境下的程序调试是让开发者头痛的问题。在 IDE 中通过添加断点的方 ......