I have an array of characters I want to be removed from a string:
stops = ["[", "]", "^", "(", ")", "#", "*", "?", "~"]
I want to be able to pass the array and have all occurrences of those chars removed so that:
"str [with] unwanted# char*acters"
becomes
"str with unwanted characters"
"str [with] unwanted# char*acters".gsub(Regexp.union(stops), '')
# => "str with unwanted characters"
If you need to remove characters you can use #delete
str.delete "[]^()#*?~"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With