Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String.substringAfter(String) behaves incorrectly #204

Open
markoteittinen opened this issue Mar 27, 2024 · 0 comments
Open

String.substringAfter(String) behaves incorrectly #204

markoteittinen opened this issue Mar 27, 2024 · 0 comments

Comments

@markoteittinen
Copy link

The following simple program shows incorrect result on Kotlin Playground:

val str = "This is not that long a string"

fun main() {
    val part = str.substringAfter("is ").substringBefore(" long")
    println("Full: $str")
    println("Part: $part")
}

Obviously, it should display "not that", but instead it displays "is not that". It seems that substringAfter() includes the delimiter string "is " parameter in its return value, but it should not.

When I run the same code on Android (i.e. JVM), the result is correctly "not that"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant