What would开发者_开发百科 be the ruby code to delete whitespace after every comma in a string? I'm not sure why this didn't work..
.gsub(/[, ]/, ',')
"hello, world".gsub(/, /, ',')
The []
are used to match any of the contained characters. You are replacing every comma or space with a comma.
精彩评论