I am trying to write a few lines in Kotlin for Android to replace 0, 1 or multiple slashes at the end of an url with a single slash, but it is not working.

The code below:

```
val firstUrl = "http://my.url.com/"
val expectedResult = "http://my.url.com/" // <-- same URL

val result = firstUrl.replace(Regex("(/*)$"), "/")

// Expected result:
// > result == "http://my.url.com/"
// Got result:
// > result == "http://my.url.com//"

assert(result == expectedResult)

// Throws:
// > java.lang.AssertionError: Assertion failed
// >    ...
// >    ...

```

I have tested the same code in JavaScript (run with NodeJS) and it works.

Are there any errors in my regex?

I am using Kotlin 1.4.10:

```
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10"

```

Android version: 8.0.0

Model: Samsung Galaxy A5 2017