regex - How in ruby delete all non-digits symbols (except commas and dashes) -
i meet hard task me. has string need parse array , other elements. have troubles regexp wanna ask help.
i need delete string all non-digits, except commas (,) , dashes (-)
for example:
"!1,2e,3,6..-10" => "1,2,3,6-10" "ffff5-10...." => "5-10" "1.2,15" => "12,15" and so.
"!1,2e,3,6..-10".gsub(/[^\d,-]+/, '') # => "1,2,3,6-10"
Comments
Post a Comment