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:
01321927
Views:
19
Tracy,

Hopefully I got it better this time (I know is not perfect (First result is wrong), but it can get you started)
? HasAPhone([Suite 100 123-1234])
? HasAPhone([Bldg J (910)222-2222])

or 

? GetThePhone([Suite 100 123-1234])
? GetThePhone([Bldg J (910)222-2222])

function HasAPhone(tcString 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(tcString)
	endwith
	return loResultSet.Count = 1
endfunc


function GetThePhone(tcString 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(tcString)
	endwith
	return Iif(loResultSet.Count = 0, 'No Phone', loResultSet.Item(0).Value)
endfunc
"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
Next
Reply
Map
View

Click here to load this message in the networking platform