using gsub in ruby strings correctly -
i have expression:
channelname = rhash["channel"].gsub("'", " ")
it works fine. however, can substitute 1 character it. want add few more characters substitue. tried following:
channelname = rhash["channel"].gsub(/[':;] /, " ")
this did not work, there no substitution done on strings , no error message. tried this:
channelname = rhash["channel"].gsub!("'", " ")
this lead string blank. absolutely not desired.
i have gsub method substitute following characters space in string:
' ; :
my questions:
how can structure gsub method instances of above characters replaced space?
what happening gsub! above returning blank.
your second attempt close. problem left space after closing bracket, meaning looking 1 of symbols followed space.
try this:
channelname = rhash["channel"].gsub(/[':;]/, " ")
Comments
Post a Comment