I got this code
val numberOfStars = urlString.length - index
val result = urlString.replaceRange(index 1..urlString.length - 1,"*") //Here
I need to repeat replacing of character with "*"
by numberOfStars
. Now it replace only once. And I have result like this somehere=*
but I need if numberOfStars=5
the result will be somehere=*****
CodePudding user response:
AFAIK there is no method out of the box .... but you can do it like
val result = urlString.replaceRange(index 1..urlString.length - 1,"*".repeat(numberOfStars))