Package juzu.impl.router.regex

Examples of juzu.impl.router.regex.RE.matcher()


public class RegexTestCase extends AbstractTestCase {

  @Test
  public void testLiteral() {
    RE regex = JRegexFactory.INSTANCE.compile("abc");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
  }
View Full Code Here


  }

  @Test
  public void testSimpleGroup1() {
    RE regex = JRegexFactory.INSTANCE.compile("(abc)");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(2, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
    assertEquals(0, matches[1].getStart());
View Full Code Here

  }

  @Test
  public void testSimpleGroup2() {
    RE regex = JRegexFactory.INSTANCE.compile("a(b)c");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(2, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
    assertEquals(1, matches[1].getStart());
View Full Code Here

  }

  @Test
  public void testNonCapturingGroup() {
    RE regex = JRegexFactory.INSTANCE.compile("a(?:b)c");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
  }
View Full Code Here

    PatternBuilder pb = new PatternBuilder();
    pb.expr("^");
    pb.literal(c);
    pb.expr("$");
    RE pattern = REFactory.JAVA.compile(pb.build());
    assertTrue(pattern.matcher().matches(Character.toString(c)));
  }
}
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.