private int getFlags() { // hideous
    if (flags != 0) return flags;
    if (caseInsensitive && multiLine)
      return Pattern.CASE_INSENSITIVE | Pattern.MULTILINE;
    if (caseInsensitive) return Pattern.CASE_INSENSITIVE;
    if (multiLine) return Pattern.MULTILINE;
    return flags;
  }