use*_*243 8 ruby regex string parsing
请帮我一个正则表达式来完成下一个任务:我在某个表中有一个'cost'列,但是那里的值有所不同:
['1.22','1,22','$1.22','1,22$','$ 1.22']
Run Code Online (Sandbox Code Playgroud)
我需要删除除digits
和,
和之外的所有字符.
.所以我需要得到一个总是可以解析为Float的值.
San*_*osh 12
a.map {|i| i.gsub(/[^\d,\.]/, '')}
# => ["1.22", "1,22", "1.22", "1,22", "1.22"]
Run Code Online (Sandbox Code Playgroud)