Vitali Plagov
04/23/2020, 1:05 PM/[()\/]/g
that matches (
,)
,/
anywhere in a string. Why exactly the same pattern doesn’t work with Kotlin when I pass it to the Regex
?diesieben07
04/23/2020, 1:07 PMRegex
constructor. Please show your exact Kotlin code.Vitali Plagov
04/23/2020, 1:07 PMstr.replace(Regex("/[()/]/g"), "")
diesieben07
04/23/2020, 1:08 PM/
and /
at the start and end (they are not part of the regex and just tell JavaScript that this is a regex). Also remove the g
at the end which is a modifier and needs to be passed via the option
parameter to the Regex
constructor.diesieben07
04/23/2020, 1:09 PMg
modifier is not a thing in Kotlin's Regex implementation.Vitali Plagov
04/23/2020, 1:10 PMdiesieben07
04/23/2020, 1:11 PM/
diesieben07
04/23/2020, 1:12 PMVitali Plagov
04/23/2020, 1:13 PMVitali Plagov
04/23/2020, 1:13 PMVitali Plagov
04/23/2020, 1:13 PMKroppeb
04/23/2020, 1:38 PMnkiesel
04/24/2020, 1:29 AMreplace
is a loop around find
and not match
. So yes, str.replace(Regex("[()/]"), "")
should do what you want.