Hello,
I need to split the phone number into three fields (000) 000 0000.
Hello,
I need to split the phone number into three fields (000) 000 0000.
Run this:
sNum = “8005551212”
re = /(\d\d\d)(\d\d\d)(\d\d\d\d)/
md = re.match(sNum)
print sNum + " => "
puts “(#{md[1]}] #{md[2]}-#{md[3]}”
END
Output:
8005551212 => (800] 555-1212
HTH,
Richard
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs