I have a sample string
sentence = "Hello, world ... 123 *** ^%&*())^% %%:>"
From this string, I want to only keep the integers, characters, and spaces. For that, I have used String. replace like this
a = String.replace(sentence, ~r"[:_!@#$%^&*:|,./]", " ")
Here it’s replacing the second argument with the third one that is an empty space.
Is there any way that we can use String.replace and focus on what to keep rather than what to throw away.