473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SECOND instance in instr

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!
Jul 19 '05 #1
6 2611
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" <jo**@infosmiths.net> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
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!

Jul 19 '05 #2
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" <jo**@infosmiths.net> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
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!

Jul 19 '05 #3
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!
Jul 19 '05 #4
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)
Jul 19 '05 #5
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)
Jul 19 '05 #6
phnum = replace(phnum,"-","")
if not isnumeric(phnum) then phnum=""

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Joey Martin" <jo**@infosmiths.net> wrote in message
news:OY**************@TK2MSFTNGP12.phx.gbl...
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!

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DTB | last post by:
I am trying to convert a complex function from Oracle to SQL Server and have come across Oracle's Instr() function. I see SQL Server has CHARINDEX() which is similar, however it does not provide...
10
by: Jon | last post by:
I want to count the number of instances of a certain string(delimiter) in another string. I didn't see a function to do this in the framework (if there is, please point me to it). If not, could...
4
by: Sullivan WxPyQtKinter | last post by:
In python, these expression seems yields the same result: inputstring='ABC' print inputstring.lower() print lower(inputstring) print string.lower(inputstring) result: abc
4
by: fischerspooner | last post by:
Hi, I'm banging my head against the desk because I can't find a solution for the following simple problem. Case: There is a column in a table that has FamilyName and FirstName(s) in one field....
12
by: rodchar | last post by:
hey all, i'm getting a result that i don't understand i have a string "test1, test2" If InStr("test1") and InStr("test2") Then 'Inside EndIf The inside is not running for some reason. Any...
0
by: jonathan184 | last post by:
This is part of the perl script. Basically i want to try and get the second line of the error message. Now the whole error which is 5 lines long will come up if i use $Errormsg So basically i...
3
by: lstrudeman | last post by:
Hello; A friend gave me this syntax and they are unavailable at the moment and I need this asap. I am trying to figure out how SQL figures this out. Below the syntax takes a field in a file and...
3
by: csgraham74 | last post by:
Hi Guys, I was wondering if soemone could help me. Im trying to write a piece of code that queries a field in ms access for a keyword. what i want to do is count the number of times the...
6
by: vjp2.at | last post by:
Suppose I have a string "12-34 56th Loway" and I want to know if 4 is odd. Is there someway to do it with STR$ and MID$ &al
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.