Why not just use the regex character class digit with a reReplace and
remove anything that's not a digit and then just check to make sure that
you have 10 numbers.  Then, store it as a 10-digit number in the
database and you can format them all exactly the same on output.
Obviously, this is much tougher with international, but works quite well
for US numbers.

John

-----Original Message-----
From: Matt Robertson [mailto:[EMAIL PROTECTED]
Sent: Monday, August 02, 2004 2:04 PM
To: CF-Talk
Subject: Re: Stupid telephone regex question

Sorry, I should have specified U.S. phone number. Realized it right
after my post.

The regex *should* accept numbers formatted as such:

000-000-0000
(000) 000-0000
(000)000-0000
000.000.0000

where the zeroes represent a digit range from 2-9 in the first position,
of area code and prefix, and any digit in any other position.

I picked up this regex from a web site somewhere.  Can't find it at the
moment.

The regex from Ben's book is

\(?[2-9]\d\d\)?[ -]?[2-9]\d\d-\d{4}

and accepts a more limited range.  I could live with that, actually.
Not married to the accept-multiple-formats idea.

Yes this is CF 6.1.  Don't have to make this one backward-compatible.

ReFind is being used as part of a generic field validation processor.
I can plug in a custom regex but the method of applying it has to be via
ReFind.  If refind returns zero I know the test failed.

The only time refind hasn't worked for me as shown is when I screw up
the regex.  Is there a better way to do this?

--
--Matt Robertson--
MSB Designs, Inc.
mysecretbase.com
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to