Package java.util.regex

Examples of java.util.regex.MatchResult.start()


      // Verify group start returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.start(1));
      Assert.assertEquals(-1, m.start(2));
      Assert.assertEquals(m.start(), result.start());
      Assert.assertEquals(m.start(1), result.start(1));
      Assert.assertEquals(m.start(2), result.start(2));

      // Verify group end returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.end(1));
      Assert.assertEquals(-1, m.end(2));
View Full Code Here


      // Verify group start returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.start(1));
      Assert.assertEquals(-1, m.start(2));
      Assert.assertEquals(m.start(), result.start());
      Assert.assertEquals(m.start(1), result.start(1));
      Assert.assertEquals(m.start(2), result.start(2));

      // Verify group end returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.end(1));
      Assert.assertEquals(-1, m.end(2));
      Assert.assertEquals(m.end(), result.end());
View Full Code Here

        int byteCount = 0;
        int matches = 0;
        while ((matches < maxCount) && (line = reader.readLine()) != null) {
            result = match(line);
            if (result != null) {
                printMatch(line.substring(result.start(), result.end()),
                           name, reader.getLineNumber(), byteCount + result.start());
                rc = 0;
                matches++;
            }
            byteCount += line.length();
View Full Code Here

        int matches = 0;
        while ((matches < maxCount) && (line = reader.readLine()) != null) {
            result = match(line);
            if (result != null) {
                printMatch(line.substring(result.start(), result.end()),
                           name, reader.getLineNumber(), byteCount + result.start());
                rc = 0;
                matches++;
            }
            byteCount += line.length();
        }
View Full Code Here

            MatchResult currentResult = getMatchResult(matcher, true);
            if (currentResult != null) {
                // JW: how to compare match results reliably?
                // the group().equals probably isn't the best idea...
                // better check pattern?
                if ((currentResult.start() == 0) &&
                   (!lastMatchResult.group().equals(currentResult.group()))) {
                    updateStateAfterFound(currentResult, start);
                    return true;
                }
            }
View Full Code Here

        Matcher matcher = p.matcher(command);
        while (matcher.find()) {
            MatchResult posMatch = matcher.toMatchResult();

            if (n.isLiteral()) {
                if (delims.isInsideLiteral(posMatch.start(1), posMatch.end(1))) {
                    throw new ARQException(
                            "Command string is vunerable to injection attack, variable ?"
                                    + var
                                    + " appears inside of a literal and is bound to a literal which provides a SPARQL injection attack vector");
                }
View Full Code Here

            MatchResult posMatch = matcher.toMatchResult();

            Node n = this.positionalParams.get(index);
            if (n == null)
                continue;
            this.validateSafeToInject(command, index, posMatch.start(1) + adj, n);

            String nodeStr = this.stringForNode(n, context);
            command = command.substring(0, posMatch.start() + adj) + nodeStr + command.substring(posMatch.start() + adj + 1);
            // Because we are using a matcher over the string state prior to
            // starting replacements we need to
View Full Code Here

            if (n == null)
                continue;
            this.validateSafeToInject(command, index, posMatch.start(1) + adj, n);

            String nodeStr = this.stringForNode(n, context);
            command = command.substring(0, posMatch.start() + adj) + nodeStr + command.substring(posMatch.start() + adj + 1);
            // Because we are using a matcher over the string state prior to
            // starting replacements we need to
            // track the offset adjustments to make
            adj += nodeStr.length() - 1;
        }
View Full Code Here

            if (n == null)
                continue;
            this.validateSafeToInject(command, index, posMatch.start(1) + adj, n);

            String nodeStr = this.stringForNode(n, context);
            command = command.substring(0, posMatch.start() + adj) + nodeStr + command.substring(posMatch.start() + adj + 1);
            // Because we are using a matcher over the string state prior to
            // starting replacements we need to
            // track the offset adjustments to make
            adj += nodeStr.length() - 1;
        }
View Full Code Here

    int groupCount = matcher.groupCount();
    while (matcher.find()) {
      RegExpRuleMatch ruleMatch = new RegExpRuleMatch(this);
      MatchResult matchResult = matcher.toMatchResult();
      for (int i = 0; i <= groupCount; i++) {
        int begin = matchResult.start(i);
        int end = matchResult.end(i);
        List<Type> types = groupTypes.get(i);
        if (types != null) {
          createAnnotations(i, delta, begin, end, types, fa, matchResult, ruleMatch, stream);
        } else if (i == 0) {
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.