David,

I believe that regular expressions is what you may be looking for..

>> s = "(0045) 444-5555"
=> "(0045) 444-5555"
>> codes = s.match /(\(\d+\))?\s*(\d{3})(\s*-\s*)?(\d{4})/
=> #<MatchData "(0045) 444-5555" 1:"(0045)" 2:"444" 3:"-" 4:"5555">
>> codes[0]
=> "(0045) 444-5555"
>> codes[1]
=> "(0045)"
>> codes[2]
=> "444"
>> codes[4]
=> "5555"

hth..


David Liwoch wrote:

> 
> I figure code dosn't work if user puts spaces in his phonenumber. I
> guess that can be fixed with a gsub " ", "".. something like that.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to