SECOND instance in instr

J

Joey Martin

I have a script that looks for a phone number. I use an instr to see if
it finds a - for the phone number. I them grab the 3 characters before
and 4 after for the phone number. Works well, except when someone uses
the - in the text.

How can look for the second instance of the - if the right 4 characters
past the - are not numeric?

Thanks!



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Steven Burn

Simplest way;

1. Allow numerics only

'// Can be done in ASP or client side Javascript/JScript

2. Check the length

'// Can be done in either ASP or client side Javascript/JScript

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
A

Aaron [SQL Server MVP]

This is going to take you down the road of pulling your hair out, as people
have all kinds of interesting ways to format phone numbers when given the
chance. How about, instead of one big free text entry field, you have three
separate fields, one for area, one for city, and one for the last four
digits? Then you just check the length/numeric of each of the three parts.
You don't have to worry about -, (), ., etc. You could make this dynamic if
you also need to support UK and other country phone formats. When they
select their country you can use client-side script to change the designated
phone number. (You might also do something similar for zip/postal codes.)
 
J

Joey Martin

I am parsing existing data so I do not have an option to change the text
string.

Some entries will have xxx-xxx-xxxx, some have xxx-xxxx and some have
text-text.

I need to be able to ignore anything that is text-text, but bring in the
rest. I do not need to separate then with area code, just smash it all
together is fine.



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
E

Evertjan.

Aaron [SQL Server MVP] wrote on 07 jul 2004 in
microsoft.public.inetserver.asp.general:
You could make this dynamic if
you also need to support UK and other country phone formats.

The OP did not make it clear he was talking statesside numbers.

;-}
 
E

Evertjan.

Joey Martin wrote on 07 jul 2004 in
microsoft.public.inetserver.asp.general:
Some entries will have xxx-xxx-xxxx, some have xxx-xxxx and some have
text-text.

regex match:

/(\d\d\d-)?\d\d\d-\d\d\d\d/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top