I have this expression:
channelName = rhash["Channel"].gsub("'", " ")
it works fine. However, I can only substitute 1 character with it. I want to add a few more characters to substitue. So I tried the following:
channelName = rhash["Channel"].gsub(/[':;] /, " ")
This did not work, that is there was no substitution done on strings and no error message. I also tried this:
channelName = rhash["Channel"].gsub!("'", " ")
This lead to a string that was blank. So absolutely not what I desired.
I would like to have a gsub method to substitute the following characters with a space in my string:
' ; :
My questions:
How can I structure my gsub method so that all instances of the above characters are replaced with a space?
What is happening with gsub! above as its returning a blank.
xoption correct? ruby-doc.org/core-2.0/Regexp.html#label-Options - squiguyString#trfor simple things like this? - mu is too shorttris probably faster thangsubbut (a) regex engines can be surprisingly fast, (b) the difference is probably irrelevant for all practical purposes, and (c) you could always benchmark it and see. - mu is too short