Example:
// Java
System.out.println("one;two;th/;ree".split("(?<!/);").length); // 3
// Kotlin
println("one;two;th/;ree".split("(?<!/);").size) // 1
How to correct this?
In your Kotlin example you're not splitting by a Regex
but by a String
.
Try the following:
println("one;two;th/;ree".split(Regex("(?<!/);")).size) // 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With