bianbian coding life

便便代码人生: 关注技术, 翻译文档, 偶尔动动手

[原]Java正则表达式获取匹配结果

Posted by bianbian on 2006-12-02 22:41

本文Tags: ,

  1. Pattern p = Pattern.compile("正则表达式");
  2. Matcher m = p.matcher("预匹配的字符串");
  3. if(m.matches()) {
  4.     m.group(1); //匹配第1项
  5.     m.group(2); //匹配第2项
  6. }

有关正则表达式语法,请参考:文档 Document

标签: ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

(required)