Android - how to replace part of a string by another string?

前端 未结 6 860
夕颜
夕颜 2020-11-27 17:07

I have strings with some numbers and english words and I need to translate them to my mother tongue by finding them and replacing them by locallized version of this word. Do

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 17:58

    In kotlin there is no replaceAll, so I created this loop to replace repeated values ​​in a string or any variable.

     var someValue = "https://www.google.com.br/"
        while (someValue.contains(".")) {
            someValue = someValue.replace(".", "")
        }
    Log.d("newValue :", someValue)
    // in that case the stitches have been removed
    //https://wwwgooglecombr/
    

提交回复
热议问题