[Solved] How to split a string at the n’th occurrence of a specific separator in Java [closed]
You can do something like this: Pattern pat = Pattern.compile(“((?:[^\u0003]*\u0003){30}[^\u0003]*)\u0003(.*)”); Matcher matcher = pat.matcher(input); if (matcher.matches()) { String leftPart = matcher.group(1); String rightPart = matcher.group(2); } The pattern works as follows: The first capture group finds a substring with exactly 30 occurrences of the separator \u0003; the subpattern that finds a substring with no separators, … Read more