Possible reason:
This is similar to the Java version error your Android uses, which has been fixed in later versions of Java.
\G can be thought of as an anchor that represents
- end of previous match
- beginning of line (if no match is found)
and like any zero length anchor.
I suspect that the main part of this error is that \G perceived as the inverse of the whole previous match, and not its end, and since the previous match may have any appearance, complains about it because it cannot determine obvious maximum length.
Way around.
Avoid split("(?<=\\Gwhatever)") .
Instead of looking for delimiters, use the Matcher class to find() things you want from the text. So your code might look like this:
String myStr = "0123456789012345678901234567890123456789012345678901234567890123456789"; Matcher m = Pattern.compile(".{1,16}").matcher(myStr); while (m.find()) { String s = m.group();
Output:
0123456789012345 6789012345678901 2345678901234567 8901234567890123 456789
Pshemo Apr 13 '15 at 11:27 2015-04-13 11:27
source share