you should use:
s.split("(?<=\\G.{20})");
\Gis a zero-width statement that corresponds to the position at which the previous match ended. If there was no previous match, it matches the beginning of the input, just like \A. The attached lookbehind corresponds to a position consisting of 20 characters from the end of the last match.
source
share