This code totally runs when I am applying it outside android, that is, in a pure java enviroment. (There is a link that says it is a doublicate of the question, but its not) I want to know why it runs in java without android, but crashes in android.
String[] ar = new String[iters];
ar = myStr.split("(?<=\\G.{16})");
However, when I apply the same in android enviroment, I get the following exception
04-13 13:50:22.255: E/AndroidRuntime(2147): FATAL EXCEPTION: main
04-13 13:50:22.255: E/AndroidRuntime(2147): java.util.regex.PatternSyntaxException: Look-behind pattern matches must have a bounded maximum length near index 12:
04-13 13:50:22.255: E/AndroidRuntime(2147): (?<=\G.{16})
(?<=\\G.whatever)approach. Even if it works in standard Java, it does it against regex engine assumptions that look-behind needs to have maximal length and we don't know what length\\Grepresents. So as you see this behaviour can change in newer versions of Java (or Java-like environments like Android). Instead usePatternandMatcherclasses likeMatcher m = Pattern.compile(".{16}").matcher(myStr); while (m.find){ String s = m.group(); ... }m.group()as you want (in my code I print it, but you can store it in some List like ArrayList and reuse later).