专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »博文摘选 » no matches found (正则表达式使用中常见错误) »正文

no matches found (正则表达式使用中常见错误)

来源: 发布时间:星期二, 2009年12月8日 浏览:0次 评论:0


Pattern p = Pattern.compile ( ".*?_(\\d*_\\d*)" );

Matcher m = p.matcher(jobName);//jobName is a . e.g. firstJob_1_0

String version = m.group(m.groupCount);

如果只是这样写 , 执行时候就会报 no matches found.

找了好多资料 , 大部分都说要 :

while (m.find)

    String version = m.group(m.groupCount);

试过了 , 不成功 .

试了上午 , 终于成功了 , 代码如下 :

(m.matches){// 关键是这行代码 . 加上就好了 .

       version = m.group(m.groupCount);

    }

          

标签:
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: