{"record":{"id":"03b538b450b7d60f","repo":"stanfordnlp/CoreNLP","slug":"valuesplit-separatorregex-doesn-t-match","errorCode":null,"errorMessage":"valueSplit: \" + separatorRegex + \" doesn't match \" + str","messagePattern":"valueSplit: \" \\+ separatorRegex \\+ \" doesn't match \" \\+ str","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/StringUtils.java","lineNumber":632,"sourceCode":"    List<String> ret = new ArrayList<>();\n    while ( ! str.isEmpty()) {\n      Matcher vm = vPat.matcher(str);\n      if (vm.lookingAt()) {\n        ret.add(vm.group());\n        str = str.substring(vm.end());\n        // String got = vm.group();\n        // log.info(\"vmatched \" + got + \"; now str is \" + str);\n      } else {\n        throw new IllegalArgumentException(\"valueSplit: \" + valueRegex + \" doesn't match \" + str);\n      }\n      if ( ! str.isEmpty()) {\n        Matcher sm = sPat.matcher(str);\n        if (sm.lookingAt()) {\n          str = str.substring(sm.end());\n          // String got = sm.group();\n          // log.info(\"smatched \" + got + \"; now str is \" + str);\n        } else {\n          throw new IllegalArgumentException(\"valueSplit: \" + separatorRegex + \" doesn't match \" + str);\n        }\n      }\n    } // end while\n    return ret;\n  }\n\n\n  /**\n   * Return a String of length a minimum of totalChars characters by\n   * padding the input String str at the right end with spaces.\n   * If str is already longer\n   * than totalChars, it is returned unchanged.\n   */\n  public static String pad(String str, int totalChars) {\n    return pad(str, totalChars, ' ');\n  }\n\n  /**","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/StringUtils.java#L614-L650","documentation":"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>').","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the string at the failing position and use a separatorRegex matching the actual delimiter","Normalize the input first (replace ';' with ',' etc.) before splitting","Broaden the separator regex, e.g. '[,;]\\\\s*' to accept multiple delimiters"],"exampleFix":"// before\nStringUtils.valueSplit(\"[0-9]+\", \",\", \"1;2;3\"); // wrong separator\n// after\nStringUtils.valueSplit(\"[0-9]+\", \"[;,]\\\\s*\", \"1;2;3\");","handlingStrategy":"validation","validationCode":"if (!str.matches(\"^\" + valueRegex + \"(\" + separatorRegex + valueRegex + \")*$\"))\n  throw new IllegalArgumentException(\"Not a value/separator list: \" + str);","typeGuard":null,"tryCatchPattern":"try {\n  List<String> vals = StringUtils.valueSplit(valueRegex, sepRegex, str);\n} catch (IllegalArgumentException e) {\n  log.error(\"Separator mismatch in: \" + str);\n}","preventionTips":["Confirm the actual delimiter in your data and match separatorRegex to it","Pre-normalize delimiters (replace ';' with ',') when formats may vary","Prefer a full-string regex sanity check before parsing"],"tags":["java","regex","string-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}