---
title: "java中使用正则表达式"
author: "nowing"
date: "2011-06-03T11:30:23Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2011-06-03T11:30:23Z"
id: 1069407
url: "https://nowing.iteye.com/blog/1069407"
---

使用apache的oro包
//匹配  'abc@jcc.inn'  2011/06/03 9:50

        String regrex = "'(*?+)*@(*?+)+{2,3}({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);
        }