import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegex {
public static void main(String[] args) {
//时间正则表达式
String reg = "(.*)-(.*) (.*):(.*)";
String reg2 = "(.*)(0[1-9]|1[1-2])/(0[1-9]|[1-2]\\d|3[0-1]) ([0-2][0-9]):([0-5]\\d)(.*)";

Pattern pattern = Pattern.compile(reg2);

//时间String
String timeStr = "(06/06 15:50)";
Matcher matcher = pattern.matcher(timeStr);

while(matcher.find()){
for(int i = 1;i<=matcher.groupCount();i++){
System.out.println(matcher.group(i));
}
}
}
}

/*
** 正则: (今天|(.*)月(.*)日 )([0-2][0-9]):([0-5]\\d)
时间:今天17:19 或 6月1日 09:53
*
* 正则:(\\d{4})-(0[1-9]|1[1-2])-(0[1-9]|[1-2]\\d|3[0-1]) ([0-2][0-4]):([0-5]\\d):([0-5]\\d)
时间:2016-05-23 23:35:41
*
* 正则:(0[1-9]|1[1-2])-(0[1-9]|[1-2]\\d|3[0-1]) ([0-2][0-9]):([0-5]\\d)
时间:05-04 06:33

正则:(.*)(0[1-9]|1[1-2])/(0[1-9]|[1-2]\\d|3[0-1]) ([0-2][0-9]):([0-5]\\d)(.*)
时间:(06/06 15:50)
* */

java.util.regx Demo的更多相关文章

  1. java.util.Timer demo good

    package timer; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import org ...

  2. Iterator之java.util.ConcurrentModificationException

    在运行以下代码时,会报java.util.ConcurrentModificationException异常, public class Demo { public static void main( ...

  3. Java NIO UDP DEMO

    今天有人问我Netty的UDP怎么使用,我自己尝试的去写一个Demo,在网上搜索了一下,关于Netty的UDP实现还是很少的,所以,今天写下这篇文章用来记录今天的一个简单Demo实现 不使用Netty ...

  4. java集合--java.util.ConcurrentModificationException异常

    ConcurrentModificationException 异常:并发修改异常,当方法检测到对象的并发修改,但不允许这种修改时,抛出此异常.一个线程对collection集合迭代,另一个线程对Co ...

  5. java.util.concurrent包API学习笔记

    newFixedThreadPool 创建一个固定大小的线程池. shutdown():用于关闭启动线程,如果不调用该语句,jvm不会关闭. awaitTermination():用于等待子线程结束, ...

  6. java.util.concurrent 多线程框架

    http://daoger.iteye.com/blog/142485 JDK5中的一个亮点就是将Doug Lea的并发库引入到Java标准库中.Doug Lea确实是一个牛人,能教书,能出书,能编码 ...

  7. JAVA长连接demo

    http://blog.csdn.net/caomiao2006/article/details/38830475 JAVA长连接demo 2014-08-25 23:20 4767人阅读 评论(2) ...

  8. java.util.zip - Recreating directory structure(转)

    include my own version for your reference. We use this one to zip up photos to download so it works ...

  9. 使用java.util.Properties类读写配置文件

    J2SE 1.5 以前的版本要求直接使用 XML 解析器来装载配置文件并存储设置,虽说也并非难事,相比 java.util.Properties却要做额外的解析工作.而java.util.Proper ...

随机推荐

  1. 看文章《EAI和SOA的比较》有感(1)

    <EAI和SOA的比较>http://www.cnblogs.com/asdling/archive/2007/11/26/973100.html这篇文章写的很全面,至少自己这么认为,也解 ...

  2. 免费开放的API

    1)新浪IP地址查询API接口 http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=IP地址 format有 js. ...

  3. paip.mysql 5.6 安装总结

    paip.mysql 5.6 安装总结 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/atti ...

  4. Array.prototype.slice.call(arguments) 类数组转成真正的数组

    Array.prototype.slice.call(arguments)   我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数 ...

  5. 解读eXtremeComponents代码结构--转载

    原文地址:http://blog.csdn.net/lark3/article/details/1937466 大致整理了去年写的东西,罗列如下: ec是一系列提供高级显示的开源JSP定制标签,当前的 ...

  6. EasyMock 使用方法与原理剖析--转载

    原文地址:http://www.ibm.com/developerworks/cn/opensource/os-cn-easymock/ Mock 方法是单元测试中常见的一种技术,它的主要作用是模拟一 ...

  7. nginx---reference

    nginx (pronounced "engine x") is a free open source web server written by Igor Sysoev, a R ...

  8. MySQL(9):数据表的约束(列的属性)

    1.首先我们看一下这个图: 1.NULL| not NULL是否为空      规定一个字段的值是否为NULL 2.Default value 字段默认值属性 常见的是一个字段不能为空,而且存在默认值 ...

  9. a链接中关于this的使用

    a连接点击事件用 this 时,要用 onclick='click(this)',href='javascript:void()' a连接无法使用,要看看是不是自动变成ie7或者更低

  10. docker 错误

    docker search ubuntuGet http:///var/run/docker.sock/v1.20/images/search?term=ubuntu: dial unix /var/ ...