public Pattern combinePrefixPattern()

in src/prettify/parser/CombinePrefixPattern.java [49:73]


  public Pattern combinePrefixPattern(List<Pattern> regexs) throws Exception {
    boolean ignoreCase = false;

    for (int i = 0, n = regexs.size(); i < n; ++i) {
      Pattern regex = regexs.get(i);
      if ((regex.flags() & Pattern.CASE_INSENSITIVE) != 0) {
        ignoreCase = true;
      } else if (Util.test(Pattern.compile("[a-z]", Pattern.CASE_INSENSITIVE), regex.pattern().replaceAll("\\\\[Uu][0-9A-Fa-f]{4}|\\\\[Xx][0-9A-Fa-f]{2}|\\\\[^UuXx]", ""))) {
        needToFoldCase = true;
        ignoreCase = false;
        break;
      }
    }

    List<String> rewritten = new ArrayList<String>();
    for (int i = 0, n = regexs.size(); i < n; ++i) {
      Pattern regex = regexs.get(i);
      if ((regex.flags() & Pattern.MULTILINE) != 0) {
        throw new Exception(regex.pattern());
      }
      rewritten.add("(?:" + allowAnywhereFoldCaseAndRenumberGroups(regex) + ")");
    }

    return ignoreCase ? Pattern.compile(Util.join(rewritten, "|"), Pattern.CASE_INSENSITIVE) : Pattern.compile(Util.join(rewritten, "|"));
  }