Package oi.thekraken.grok.api

Examples of oi.thekraken.grok.api.Match.captures()


    gm = g.match("guest");
    gm.captures();
    assertEquals("{USER=guest}", gm.toMap().toString());

    gm = g.match("guest1234");
    gm.captures();
    assertEquals("{USER=guest1234}", gm.toMap().toString());

    gm = g.match("john doe");
    gm.captures();
    assertEquals("{USER=john}", gm.toMap().toString());
View Full Code Here


    gm = g.match("guest1234");
    gm.captures();
    assertEquals("{USER=guest1234}", gm.toMap().toString());

    gm = g.match("john doe");
    gm.captures();
    assertEquals("{USER=john}", gm.toMap().toString());
  }

  @Test
  public void test002_numbers() throws Throwable {
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{NUMBER}");

    Match gm = g.match("-42");
    gm.captures();
    assertEquals("{NUMBER=-42}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{WORD}");

    Match gm = g.match("a");
    gm.captures();
    assertEquals("{WORD=a}", gm.toMap().toString());

    gm = g.match("abc");
    gm.captures();
    assertEquals("{WORD=abc}", gm.toMap().toString());
View Full Code Here

    Match gm = g.match("a");
    gm.captures();
    assertEquals("{WORD=a}", gm.toMap().toString());

    gm = g.match("abc");
    gm.captures();
    assertEquals("{WORD=abc}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{SPACE}");

    Match gm = g.match("abc dc");
    gm.captures();
    assertEquals("{SPACE=}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{NUMBER}");

    Match gm = g.match("Something costs $55.4!");
    gm.captures();
    assertEquals("{NUMBER=55.4}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{NOTSPACE}");

    Match gm = g.match("abc dc");
    gm.captures();
    assertEquals("{NOTSPACE=abc}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{QUOTEDSTRING:text}");

    Match gm = g.match("\"abc dc\"");
    gm.captures();
    assertEquals("{text=abc dc}", gm.toMap().toString());

  }

  @Test
View Full Code Here

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{UUID}");

    Match gm = g.match("61243740-4786-11e3-86a7-0002a5d5c51b");
    gm.captures();
    assertEquals("{UUID=61243740-4786-11e3-86a7-0002a5d5c51b}", gm.toMap().toString());

    gm = g.match("7F8C7CB0-4786-11E3-8F96-0800200C9A66");
    gm.captures();
    assertEquals("{UUID=7F8C7CB0-4786-11E3-8F96-0800200C9A66}", gm.toMap().toString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.