I'm having a problem with a specific regex that is returning a different value than expected when running in Android Studio.
Scenario:
The code is simple:
val regex = "(?<=N|E|\\G)\\d{2}(?=\\d*$)".toRegex()
print("${regex.findAll("N2032354345").count()}")
This should print 5 as there are 5 matches in this string (https://regex101.com/r/6PDbkI/1) and if we run in on Ideone.com or in Kotlin Playground, the result is the expected 5.
However, in Android Studio, the result is 1:
Theory:
It seems that the regex in Android Studio is failing to use the \G
operator (which might be related to Kotlin split with regex work not as expected)
Anyone faced the same problem? Is there any way to change the regex to a similar one that isn't failing in Android Studio? Am I missing some setting?