Hey thanks for this and the RegExTest.zip
Would it take much to modify this to also test for international phone number format?
In the UK we don't use brackets in phone numbers (usually) but I would like to have a function that tests to see if a string 'could' be a valid phone number before sending it off to an SMS function.
A UK phone number always begins with zero like:
07951 292534
or
07888 211549
unless entered with the international code preceded by a plus sign which represents two zeros in which case you miss out the leading zero such as
+447951 292534
or
+447888 211549
Could this function be written to only return a string of numbers if they were the minimum length for a phone number and not over the max length for a phone number (if there is one) perhaps replace the + sign with two zeros, then strip out any spaces and brackets and any non numerics (perhaps the minus sign) then test for length and return if within min and max length?
so I could get the string, send it to the function, if the function returns a string then I know it 'could' be a valid phone number something like:
DIM s as String = "+44 (7888) - 211549"
s = CBVPN(s) ' now if s contains anything it 'could' be a valid phone number
and in this case s would now be 00447888211549 so...
IF s <> "" Then GoForIt(s)
So the question is, what's the min length for a phone number dialed over the cellular network and what's the max length?
Would a valid phone number always begin with at least one zero?
Sorry, bit rusty at RegEx
Actually this function might be handy for others but I think I will demand that the phone number be entered without any spaces or special characters and that international format numbers start with two zeros
Should make life easier