String.split() *not* on regular expression?

A general solution using just Java SE APIs is:

String separator = ...
s.split(Pattern.quote(separator));

The quote method returns a regex that will match the argument string as a literal.

Leave a Comment