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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -