Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find a phone number inside a string
Message
 
To
05/06/2008 13:42:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01321918
Message ID:
01321926
Views:
16
Tracy,

As I see the link given to you by Naomi says "No reg exp please" I will assume there was no reg exp there so I show you a solution using them, if there was one in that thread accept my apologies but I did not read it.

I used the pattern that you can found here: http://regexlib.com/DisplayPatterns.aspx?categoryId=7&cattabindex=2
? isPhone("123-1234")
? isPhone("(910)222-2222")
? isPhone("(123) 456-7890")
? isPhone("(123) 456-7890 x123")
? isPhone("(123) 456-7890 x123x")
? isPhone("(123) 456-7890 x123 x123")
? isPhone("(123) 456-7890 x")

function isPhone(tcNumber as String) as Boolean
	loRegEx					= Createobject('VBScript.RegExp')
	with loRegEx
		.Pattern		= "((\(\d{3}\) ?)|(\d{3}[- \.]))?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$"
		.IgnoreCase		= .T.
		loResultSet		= .Execute(tcNumber)
	endwith
	return loResultSet.Count = 1
endfunc
[Update]

Oh.. I see I made a mistake reading the question... just a second...
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform