I use this regex to split a string at every say 3rd position:
String []thisCombo2 = thisCombo.split(\"(?<=\\\\G...)\");
where the 3 dots
If you want to build that regex string you can set the split length as a parameter.
public String getRegex(int splitLength) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < splitLength; i++) builder.append("."); return "(?<=\\G" + builder.toString() +")"; }