From: "David A. Black" Date: 2007-09-25T16:20:57+09:00 Subject: Re: Extract numbers from string --1926193751-1659981201-1190704791=:4353 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1659981201-1190704791=:4353" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-1659981201-1190704791=:4353 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Tue, 25 Sep 2007, Pe=F1a, Botp wrote: > From: Nicholas Clare [mailto:nickclare@gmail.com] > # new_num =3D old_num.scan(/\d/).join('') > lose this ^^ > > irb(main):003:0> old_num.scan(/\d/).join > =3D> "5551115555" > > also, > > irb(main):014:0> old_num.gsub(/[^\d]/,"") > =3D> "5551115555" Don't forget \D: old_num.gsub(/\D/, "") David --=20 Upcoming training from Ruby Power and Light, LLC: * Intro to Ruby on Rails, Edison, NJ, October 23-26 * Advancing with Rails, Edison, NJ, November 6-9 Both taught by David A. Black. See http://www.rubypal.com for more info! --1926193751-1659981201-1190704791=:4353-- --1926193751-1659981201-1190704791=:4353--