import java.util.* fun main(args: Array) { val firstUrl = "http://m...content-available-to-author-only...l.com/" val expectedResult = "http://m...content-available-to-author-only...l.com/" val result = firstUrl.replaceFirst(Regex("/*$"), "/") print(result) }