Package java.util.regex

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


    //  resolve '..'
    public static final String resolveBackpath(final String path) {
        String p = path;
        if (p.length() == 0 || p.charAt(0) != '/') { p = "/" + p; }
        Matcher qm = patternQuestion.matcher(p); // do not resolve backpaths in the post values
        int end = qm.find() ? qm.start() : p.length();
        final Matcher matcher = backPathPattern.matcher(p);
        while (matcher.find()) {
            if (matcher.start() > end) break;
            p = matcher.replaceAll("");
            matcher.reset(p);
View Full Code Here


        if (p.length() == 0 || p.charAt(0) != '/') { p = "/" + p; }
        Matcher qm = patternQuestion.matcher(p); // do not resolve backpaths in the post values
        int end = qm.find() ? qm.start() : p.length();
        final Matcher matcher = backPathPattern.matcher(p);
        while (matcher.find()) {
            if (matcher.start() > end) break;
            p = matcher.replaceAll("");
            matcher.reset(p);
        }
        return p.equals("") ? "/" : p;
    }
View Full Code Here

        p.append("(?iu)");
        int seqc = 0;
        while (query.length() > 0) {
            final Matcher m = StringMatchPattern.matcher(query);
            if (!m.matches()) break;
            p.append(".*?").append(query.substring(m.start(1) + 1, m.end(1) - 1));
            query = query.substring(m.end(1));
            seqc++;
        }
        if (seqc == 0) return QueryParams.catchall_pattern;
        p.append(".*");
 
View Full Code Here

                    break;
                default:
                    throw new RuntimeException(
                            "Undefined value for behavior: " + behavior);
            }
            sb.append(s.substring(previousEnd, matcher.start())
                        + ((varValue == null) ? matcher.group() : varValue));
            previousEnd = matcher.end();
        }
        return (previousEnd < 1) ? s
                                 : (sb.toString() + s.substring(previousEnd));
View Full Code Here

                    break;
                default:
                    throw new RuntimeException(
                            "Undefined value for behavior: " + behavior);
            }
            sb.append(s.substring(previousEnd, matcher.start())
                        + ((varValue == null) ? matcher.group() : varValue));
            previousEnd = matcher.end();
        }
        return (previousEnd < 1) ? s
                                 : (sb.toString() + s.substring(previousEnd));
View Full Code Here

    if (!booleanExpression.matches("^" + regexp + "$")) {
      Matcher matcher = Pattern.compile(regexp)
        .matcher(booleanExpression);
      List errorIndexes = new ArrayList();
      while (matcher.find()) {
        int start = matcher.start();
        if (start != 0) {
          errorIndexes.add(new Integer(start));
        }
        int end = matcher.end();
        if (end != booleanExpression.length()) {
View Full Code Here

    if (replacements.length < intGroupCount)
      throw new RuntimeException("replacements missing: " + replacements.length + " replacement(s) defined but " + intGroupCount + " groups found");

    // no groups, exchange the whole string
    if (intGroupCount == 0) {
      result = pstrSourceString.substring(0, m.start()) + replacements[0] + pstrSourceString.substring(m.end());
    }
    else {
      int index = 0;

      for (int i = 1; i <= intGroupCount; i++) {
View Full Code Here

    }
    else {
      int index = 0;

      for (int i = 1; i <= intGroupCount; i++) {
        int intStart = m.start(i);
        if (intStart >= 0) {
          String strRepl = replacements[i - 1].trim();
          if (strRepl.length() > 0) {
            if (strRepl.contains("\\") == true) {
              strRepl = strRepl.replaceAll("\\\\-", "");
View Full Code Here

    Pattern WIKI_LINK_PATTERN = Pattern.compile("\\[\\[[^\\]]*[^\\]]*\\]\\]");
    Matcher m = WIKI_LINK_PATTERN.matcher(content);
    List links = new ArrayList();
 
    while(m.find()) {
      String link = content.substring(m.start(), m.end());
      if (!link.startsWith("[[Image:") && !link.startsWith("[[Media:") &&
          (link.indexOf("http://") == -1) && (link.indexOf('&') != -1) ) {
        testOut("Migrate ampersand in: "+link);
        links.add(link); // no image, link has '&'
      }
View Full Code Here

    Pattern WIKI_LINK_PATTERN = Pattern.compile("\\[\\[[^\\]]*[^\\]]*\\]\\]");
    Matcher m = WIKI_LINK_PATTERN.matcher(content);
    List links = new ArrayList();
 
    while(m.find()) {
      String link = content.substring(m.start(), m.end());
      if (!link.startsWith("[[Image:") && !link.startsWith("[[Media:") &&
          (link.indexOf("http://") == -1) && (link.indexOf(':') != -1) ) {
        testOut("Migrate colon in: "+link);
        links.add(link); // no image, link has ':'
      }
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.