stanfordnlp/CoreNLP · error · IllegalArgumentException

valueSplit: " + separatorRegex + " doesn't match " + str

Error message

valueSplit: " + separatorRegex + " doesn't match " + str

What it means

StringUtils.valueSplit expects that between two values there is a separator matching separatorRegex. When the string still has content after a value but that content does not start with a separator match, it throws IllegalArgumentException('valueSplit: <separatorRegex> doesn't match <str>').

Solutions

  1. Inspect the string at the failing position and use a separatorRegex matching the actual delimiter
  2. Normalize the input first (replace ';' with ',' etc.) before splitting
  3. Broaden the separator regex, e.g. '[,;]\\s*' to accept multiple delimiters

Example fix

// before
StringUtils.valueSplit("[0-9]+", ",", "1;2;3"); // wrong separator
// after
StringUtils.valueSplit("[0-9]+", "[;,]\\s*", "1;2;3");
Defensive patterns

Strategy: validation

Validate before calling

if (!str.matches("^" + valueRegex + "(" + separatorRegex + valueRegex + ")*$"))
  throw new IllegalArgumentException("Not a value/separator list: " + str);

Try / catch

try {
  List<String> vals = StringUtils.valueSplit(valueRegex, sepRegex, str);
} catch (IllegalArgumentException e) {
  log.error("Separator mismatch in: " + str);
}

Prevention

When it happens

Trigger: Calling valueSplit(valueRegex, separatorRegex, str) where two values are not separated by a string matching separatorRegex, e.g. '1;2' with separator regex ',\\s*', or '1,,2' where the separator regex doesn't allow an empty field pattern mismatch.

Common situations: Data using a different delimiter than the regex assumes (semicolons vs commas, tabs vs spaces); locale or tool changes altering output format; hand-merged config lines.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/03b538b450b7d60f. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/StringUtils.java:632

    List<String> ret = new ArrayList<>();
    while ( ! str.isEmpty()) {
      Matcher vm = vPat.matcher(str);
      if (vm.lookingAt()) {
        ret.add(vm.group());
        str = str.substring(vm.end());
        // String got = vm.group();
        // log.info("vmatched " + got + "; now str is " + str);
      } else {
        throw new IllegalArgumentException("valueSplit: " + valueRegex + " doesn't match " + str);
      }
      if ( ! str.isEmpty()) {
        Matcher sm = sPat.matcher(str);
        if (sm.lookingAt()) {
          str = str.substring(sm.end());
          // String got = sm.group();
          // log.info("smatched " + got + "; now str is " + str);
        } else {
          throw new IllegalArgumentException("valueSplit: " + separatorRegex + " doesn't match " + str);
        }
      }
    } // end while
    return ret;
  }


  /**
   * Return a String of length a minimum of totalChars characters by
   * padding the input String str at the right end with spaces.
   * If str is already longer
   * than totalChars, it is returned unchanged.
   */
  public static String pad(String str, int totalChars) {
    return pad(str, totalChars, ' ');
  }

  /**

View on GitHub (pinned to 1b7edd19c4)