Stephan van Hulst wrote:Just a thought, but could it be that your extension method conflicts with CharSequence.split()?
Stephan van Hulst wrote:Do both regular expression engines treat \G the same way for the edge case where you don't have a previous match yet?
Junilu Lacar wrote:This shows that in Java, Pattern.split(String) is symmetrical with String.split(patternString) at least. This differs from the even-length symmetry test in Kotlin.
Junilu Lacar wrote:So you don't find this behavior surprising, as in it's violating the Principle of Least Astonishment?
Jamie Zawinski wrote:Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.
Junilu Lacar wrote:The rub in this is that the Kotlin documentation for split presents the versions that take Regex and Pattern together, implying that they behave the same way when in fact, they don't.
The only way to get consistency in behavior is if you explicitly specify a negative limit for Pattern.split() which kind of contradicts the whole "limit: Int = 0" default specification in the signature.
Stephan van Hulst wrote:
I think you're confused. s.split(regex) and s.split(pattern) have exactly the same output. s.split(pattern) is inconsistent with pattern.split(s).