regexing through numbers?

L

Lord Merlin

Can someone please give me some quidelines with this.

In our database I have various phone numbers, and they could start with 082
/ 083 / 084 / 072 / 073 / 074. How do I check any of these and change them
to 2782 / 2783 / 2784 / etc etc?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 
L

Lord Merlin

Well, it's a MSSQL DB, but that doesn't really matter, cause I grab the info
from the DB, and then work with it,in ASP code

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message What kind of database?

What datatype is the column?

Ray at work
 
R

Roland Hall

: Well, it's a MSSQL DB, but that doesn't really matter, cause I grab the
info
: from the DB, and then work with it,in ASP code

If you're doing it in ASP and the field is text [leading zeros] then you can
just use replace:

newPhoneArea = replace(strPhoneArea,"0","27")

This assumes 0 is not used anywhere else in the area code. If it is, then:

newPhoneArea = "27" & mid(strPhoneArea,2)

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Ray at

Lord Merlin said:
Well, it's a MSSQL DB, but that doesn't really matter,

Of course it matters.
cause I grab the info
from the DB, and then work with it,in ASP code

It matters because you could most likely do this with one simple UPDATE
instead of pulling all the data into a recordset and trying to manipulate
it.
What datatype is the column?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Ray at work
 
L

Lord Merlin

: Well, it's a MSSQL DB, but that doesn't really matter, cause I grab the
info
: from the DB, and then work with it,in ASP code

If you're doing it in ASP and the field is text [leading zeros] then you can
just use replace:

newPhoneArea = replace(strPhoneArea,"0","27")

This assumes 0 is not used anywhere else in the area code. If it is, then:

newPhoneArea = "27" & mid(strPhoneArea,2)

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Hi Roland


This is what I'm looking for, newPhoneArea = "27" & mid(strPhoneArea,2).
Casuse there would very well be 0's anywhere in any phone number. Let me
work with this, thanx. I need to be able to check if it number already has
27 in front, but that I'll be able todo with this piece of code as well
then.

Re, Ray:
| It matters because you could most likely do this with one simple UPDATE
| instead of pulling all the data into a recordset and trying to manipulate
it.

This is not really an option, cause some users enter their phone numbers
with the international syntax, and some not, also this only applies to ppl
living in South africa, so I don't want todo a DB update. I think the better
solution would be though, to check if the number has got the 27 in front,
before saving it to the DB, if not change it, and then save to the DB, which
is why Roland's stuff would work nicely.
--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 

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,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top