How can i split a text field for a phone number?

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

Guest wrote: