#! /usr/bin/ruby1.8
def isPhone(theString)
  if theString =~ /^\+?1?([- ()\.]{0,3}\d){10,16}( *(x|ext)\.? *(\d{1,10}))?$/
    print "yeah " + theString + " is a valid phone number"
  else 
    print 'no   ' + theString + " is NOT a valid phone number"
  end
  print "\n"
end

isPhone("724 588-1243 ext 453")
isPhone("724 588-124 ext. 453")
isPhone("724 588-124x453")
isPhone("724 588-1243 ext. ")
isPhone("724 588-1243 ext. 453-55")
isPhone("(724) 588-1243")
isPhone("724 588 - 1243")
isPhone("724-588-1243")
isPhone("724.588.1243 x23")
isPhone("12354678")
isPhone("12354656478")
isPhone("+1 800 566 8449")
isPhone("+55 55-33-48-23")

