Hello everyone, I've got an Android application I'm developing and I need to restrict the user from entering certain symbols but allow others. Ones I'm allowing are
[ .:,/_-]
What I did:
binding.address = s?.replace("[^A-Za-z0-9 .:,/_-]".toRegex(), "")
?.replace("\\s+".toRegex(), " ")
?.replace("\\.{2,}".toRegex(), ".")
?.replace(":{2,}".toRegex(), ":")
?.replace(",{2,}".toRegex(), ",")
?.replace("_{2,}".toRegex(), "_")
?.replace("-{2,}".toRegex(), "-")
?.replace("/{2,}".toRegex(), "/")
As you can see it looks lik