开发者

Ruby: Delete space after every comma?

开发者 https://www.devze.com 2023-04-01 18:59 出处:网络
What would开发者_开发百科 be the ruby code to delete whitespace after every comma in a string?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消