@Override public Match[] find(CharSequence s) { java.util.regex.Matcher matcher = get(s); if (matcher.find()) { Match[] matches = new Match[1 + matcher.groupCount()]; for (int i = 0;i <= matcher.groupCount();i++) { if (matcher.group() != null) { matches[i] = new Match(matcher.start(i), matcher.end(i), matcher.group(i)); } else { matches[i] = NULL_MATCH; } } return matches; } else { return NO_MATCHES; } } };
int nextPos = matches[0].getEnd(); Path nextPath = path.subPath(nextPos); for (int j = 0;j < param.matchingRegex.length;j++) { RE.Match match = matches[index + j]; if (match.getEnd() != -1) { String value; if (!param.preservePath) { StringBuilder sb = new StringBuilder(); for (int from = match.getStart();from < match.getEnd();from++) { char c = path.charAt(from); if (c == child.router.separatorEscape && !path.isEscaped(from)) { value = match.getValue();
int nextPos = matches[0].getEnd(); Path nextPath = path.subPath(nextPos); for (int j = 0;j < param.matchingRegex.length;j++) { RE.Match match = matches[index + j]; if (match.getEnd() != -1) { String value; if (!param.preservePath) { StringBuilder sb = new StringBuilder(); for (int from = match.getStart();from < match.getEnd();from++) { char c = path.charAt(from); if (c == child.router.separatorEscape && !path.isEscaped(from)) { value = match.getValue();
@Override public Match[] find(CharSequence s) { jregex.Matcher matcher = get(s); if (matcher.find()) { Match[] matches = new Match[matcher.groupCount()]; for (int i = 0;i < matcher.groupCount();i++) { if (matcher.isCaptured(i)) { matches[i] = new Match(matcher.start(i), matcher.end(i), matcher.group(i)); } else { matches[i] = NULL_MATCH; } } return matches; } else { return NO_MATCHES; } } };
@Override public Match[] find(CharSequence s) { jregex.Matcher matcher = get(s); if (matcher.find()) { Match[] matches = new Match[matcher.groupCount()]; for (int i = 0;i < matcher.groupCount();i++) { if (matcher.isCaptured(i)) { matches[i] = new Match(matcher.start(i), matcher.end(i), matcher.group(i)); } else { matches[i] = NULL_MATCH; } } return matches; } else { return NO_MATCHES; } } };
@Override public Match[] find(CharSequence s) { java.util.regex.Matcher matcher = get(s); if (matcher.find()) { Match[] matches = new Match[1 + matcher.groupCount()]; for (int i = 0;i <= matcher.groupCount();i++) { if (matcher.group() != null) { matches[i] = new Match(matcher.start(i), matcher.end(i), matcher.group(i)); } else { matches[i] = NULL_MATCH; } } return matches; } else { return NO_MATCHES; } } };
@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()); assertEquals(2, matches[1].getEnd()); assertEquals("b", matches[1].getValue()); }
@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()); assertEquals(3, matches[1].getEnd()); assertEquals("abc", matches[1].getValue()); }
@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()); } }
@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()); } }
@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()); assertEquals(2, matches[1].getEnd()); assertEquals("b", matches[1].getValue()); }
@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()); assertEquals(3, matches[1].getEnd()); assertEquals("abc", matches[1].getValue()); }