com.cloudera.cdk.morphline.shaded.com.google.code.regexp.Pattern

Here are the examples of the java api class com.cloudera.cdk.morphline.shaded.com.google.code.regexp.Pattern taken from open source projects.

1. GrokDictionaryTest#testGrokISO8601()

Project: cdk
File: GrokDictionaryTest.java
@Test
public void testGrokISO8601() {
    String str = "{ dictionaryFiles : [target/test-classes/grok-dictionaries/grok-patterns] }";
    GrokDictionaries dicts = new GrokDictionaries(ConfigFactory.parseString(str), new Configs());
    Pattern pattern = dicts.compileExpression("%{TIMESTAMP_ISO8601:timestamp}");
    assertTrue(pattern.matcher("2007-03-01T13:00:00").matches());
    assertTrue(pattern.matcher("2007-03-01T13:00:00Z").matches());
    assertTrue(pattern.matcher("2007-03-01T13:00:00+01:00").matches());
    assertTrue(pattern.matcher("2007-03-01T13:00:00+0100").matches());
    assertTrue(pattern.matcher("2007-03-01T13:00:00+01").matches());
    assertFalse(pattern.matcher("2007-03-01T13:00:00Z+01:00").matches());
}

2. MorphlineTest#testGrokSeparatedValues()

Project: cdk
File: MorphlineTest.java
@Test
public void testGrokSeparatedValues() throws Exception {
    String msg = "hello\tworld\tfoo";
    Pattern pattern = Pattern.compile("(?<word>.+?)(\\t|\\z)");
    Matcher matcher = pattern.matcher(msg);
    List<String> results = new ArrayList();
    while (matcher.find()) {
        //System.out.println("match:'" + matcher.group(1) + "'");
        results.add(matcher.group(1));
    }
    assertEquals(Arrays.asList("hello", "world", "foo"), results);
}