gabrielfv
04/22/2020, 6:23 PMval url = "<https://google.com/>"
val rgxReplace = url.replace("/".toRegex(), "\\/")
val strReplace = url.replace("/", "\\/")
println(rgxReplace) // outputs: <https://google.com/>
println(strReplace) // outputs: https:\/\/google.com\/
gabrielfv
04/22/2020, 6:24 PM"\\\\/"
to get a similar resultRuckus
04/22/2020, 6:25 PMgabrielfv
04/22/2020, 6:27 PMgabrielfv
04/22/2020, 6:28 PM/
character in Gson serialization. My backend needs that, although I'm slightly concerned about possible side effects like breaking Base64.Ruckus
04/22/2020, 6:30 PM\
in regex, you need to escape it: \\
. To get a literal \\
in a Kotlin string, you need to escape both: \\\\
.Volodymyr Galandzij
04/23/2020, 6:47 AMurl.replace("/".toRegex(), """\\/""")