Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个字符串:
"item one :value1 , item2: value2,item3 : value3"
我怎样才能得到这个?:
"item one:value1,item2:value2,item3:value3"
(我需要删除“,”分隔的项目之间和“:”分隔的项目之间的空格)
irb(main):008:0> "item one :value1 , item2: value2,item3 : value3".gsub(/\s*([,:])\s*/,'\1') => "item one:value1,item2:value2,item3:value3"