Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 To: Nic Cross
  Where is Nic Cross?
 California - United States
 Nic Cross
Subject: RE: Parse Phone Number
Thread ID: 79002 Message ID: 79034 # Views: 3 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Wednesday, October 12, 2005 12:28:34 PM         

Hi Nic
> I am going to create another field that will house the numeric parts of the number; however, I do not remember how to extract the number portions from the original field.

You can use CHRTRAN to do this as Dale suggested.

However, if you only want the numbers the real trick is to use a double CHRTRAN. First get rid the numbers and use the result as the input to a second CHRTRAN - these can be implemented as a single line of code, but written for readability it goes like this:
lcRaw = [formatted number]
lcIntermediate = CHRTRAN( lcRaw, '0123456789', '' )
lcFinal = CHRTRAN( lcRaw, lcIntermediate, '' )
The benefit of this is that if there is anything other than the "()", "-" or " " it still gets removed and you don't have to hard-code it. As a single line it looks like this:
lcRaw = '(123) - 456_78790'
? CHRTRAN( lcRaw, CHRTRAN( lcRaw,'0123456789', '' ), '' )
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA


Parse Phone Number Posted by Nic Cross @ 10/12/2005 4:41:36 AM
RE: Parse Phone Number Posted by Bernard Bout @ 10/12/2005 5:22:13 AM
RE: Parse Phone Number Posted by Dale Dedoroy @ 10/12/2005 5:30:12 AM
RE: Parse Phone Number Posted by Andy Kramek @ 10/12/2005 12:28:34 PM
RE: Parse Phone Number Posted by Hans de Groot @ 10/13/2005 5:44:47 PM