Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > SECOND instance in instr

Reply
Thread Tools

SECOND instance in instr

 
 
Joey Martin
Guest
Posts: n/a
 
      07-07-2004
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!
 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      07-07-2004
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!


"Joey Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      07-07-2004
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.)

--
http://www.aspfaq.com/
(Reverse address to reply.)






"Joey Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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!



 
Reply With Quote
 
Joey Martin
Guest
Posts: n/a
 
      07-07-2004
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!
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      07-07-2004
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.

;-}


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      07-07-2004
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/

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      07-07-2004
phnum = replace(phnum,"-","")
if not isnumeric(phnum) then phnum=""

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Joey Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
InStr test =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 12 11-15-2006 01:27 PM
For SGI and Linux: Instr like Semaphore with a Setable Timeout clusardi2k@aol.com C++ 1 07-13-2005 01:33 PM
Preventing rogue devices - technical instr. + policies?!? Papi Cisco 0 05-23-2005 11:54 AM
Format datagrid rows based on InStr contents of list control? Kathy Burke ASP .Net 0 11-24-2003 11:32 PM
InStr, substr, Mid ??? J. Muenchbourg ASP General 1 08-13-2003 12:18 AM



Advertisments