`
nowing
  • 浏览: 82962 次
  • 来自: ...
社区版块
存档分类
最新评论

java中使用正则表达式

阅读更多
使用apache的oro包
//匹配  'abc@jcc.inn'  2011/06/03 9:50

        String regrex = "'[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\\.][a-z]{2,3}([\\.][a-z]{2})?'\\s+\\d{4}/\\d{2}/\\d{2}\\s+\\d{1,2}:\\d{2}";

        compiler = new Perl5Compiler();
        pattern = null;
        try {
            pattern = compiler.compile(regrex);
        } catch (MalformedPatternException e) {
            logger.error(e);
            return;
        }
        matcher = new Perl5Matcher();
        String line = "       'abc@jcc.inn'  2011/06/03 9:50";
        if (matcher.contains(line, pattern)) {
            MatchResult result = matcher.getMatch();
            String findStr = result.group(0);
        }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics