From: Nicholas Clare Date: 2007-09-25T15:50:28+09:00 Subject: Re: Extract numbers from string ------=_Part_675_1810576.1190703027498 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/25/07, eggie5 wrote: > > Say I have a phone number "(555) 555-5555" and I want to extract the > numbers from it. What's the most succinct way to do this? E.g.: > > old_num = "(555) 111-5555" > new_num = "5551115555" > > old_num = "555-666-7777" > new_num = "5556667777" > > > Hi, I would try new_num = old_num.scan(/\d/).join('') Hope that does what you want Nick ------=_Part_675_1810576.1190703027498--