public static StringMatcher create(String target) {
    if (target.length() == 0) return ANY;
    if (target.equals(".*")) return ANY_PATTERN;
    if (target.equals(NONE.getPattern())) return NONE;

    final List<String> branches = StringUtil.split(target,"|");
    final Set<StringMatcher> matchers = new LinkedHashSet<>();

    for (String branch : branches) {
      boolean startsWith = false;
      boolean endsWith = false;
      boolean ignoreCase = false;

      // this assumes the regex is syntactically correct
      if (branch.startsWith("(?i)")) {
        ignoreCase = true;
        branch = StringUtil.toLowerCase(branch.substring(2));
      }
      if (branch.endsWith(".*")) {
        startsWith = true;
        branch = branch.substring(0, branch.length() - 2);
      }
      if (branch.startsWith(".*")) {
        endsWith = true;
        branch = branch.substring(2);
      }

      final boolean m = analyseBranch(branch);
      if (!m) {
        try {
          return new Cache(new Pattern(target));
        }
        catch (Exception e) {
          return new Any(target, false);
        }
      }

      final StringMatcher matcher;
      if (startsWith && endsWith) {
        matcher = new Contains(branch);
      }
      else if (startsWith) {
        matcher = new StartsWith(branch);
      }
      else if (endsWith) {
        matcher = new EndsWith(branch);
      }
      else {
        matcher = new Equals(branch);
      }

      matchers.add(ignoreCase ? new IgnoreCase(matcher) : matcher);
    }

    return matchers.size() == 1 ? matchers.iterator().next() : MatcherSet.create(matchers);
  }
public static StringMatcher create(String target)