473,399 Members | 2,858 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,399 software developers and data experts.

Remove unwanted charcters from a string

Good Morning,
I have a text box on a webform I use to display a phone number. The
database field does not contain parentheses or hyphens. I want the use to
be able to change the textbox text and be able to click an update button to
save the changes to the database? My question is how do I remove the
unwanted characters and save that value to the database? I use a function
in the text attribute of the control to set the display value. like
text="<%# formatphone(databinder.eval(Container.DataItem, "phone")) %>' and
this works great. Basically i want to undo this when saving to the
database. I wanted to use a regex object but I am not familiar enough with
it to code it correctly. Any advise would be great. Thanks everyone!!

Regards,
Chris
Nov 19 '05 #1
1 1828
I figured it out. This works great!

Function unformatphone(phone as string) as string
dim val as string
val = regex.replace(phone, "\D", "")
return val
End Function

\D is any non-digit character
Sweet

"Chris Kettenbach" <in**@piasd.net> wrote in message
news:hp********************@giganews.com...
Good Morning,
I have a text box on a webform I use to display a phone number. The
database field does not contain parentheses or hyphens. I want the use to
be able to change the textbox text and be able to click an update button
to save the changes to the database? My question is how do I remove the
unwanted characters and save that value to the database? I use a function
in the text attribute of the control to set the display value. like
text="<%# formatphone(databinder.eval(Container.DataItem, "phone")) %>'
and this works great. Basically i want to undo this when saving to the
database. I wanted to use a regex object but I am not familiar enough
with it to code it correctly. Any advise would be great. Thanks
everyone!!

Regards,
Chris

Nov 19 '05 #2

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

Similar topics

11
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper...
1
by: peelman | last post by:
For some reason this is not working for me. How to remove all newline characters from a string? I have tried: myString.Replace ("\n", ""); I have also tried using TrimStart and TrimEnd...
2
by: DavidW | last post by:
I have written code using System.Web.Mail.MailMessage. Everything works fine - I send out an email. But the emails end up with "! " stuck in them. It appears to be an end of line problem but I...
1
by: Chris Kettenbach | last post by:
Good Morning, I have a text box on a webform I use to display a phone number. The database field does not contain parentheses or hyphens. I want the use to be able to change the textbox text and...
3
by: Danny Yeadon | last post by:
Hi I need to remove unwanted characters from phone numbers from my phone bill to analyse the data. Some examples are 02 48222222 i need to remove the space +61266667656 ...
8
by: Paul | last post by:
Hi, My VB is very rusty I'm afraid! What would be the most efficient way to remove the following ASCII characters from a string? à è ì ò ù À È Ì Ò Ù á é í ó ú ý Á É Í Ó Ú Ý â ê î ô û Â Ê Î Ô...
5
by: joe | last post by:
hello i have a databse program that uses char arrays to output data to reports. I would like to remove all invalid characters from the array and replace them with a blank space. I have problems...
3
by: Barkingmadscot | last post by:
I am stuck, i can workout how to remove lines from an array I have loading a text file (a Log), I know which lines a need, but the logs can be upto 30K sometimes bigger. I found trying to...
11
by: Dooza | last post by:
Using ASP/VB I need to remove unwanted commas from the end of a field that will be use in an array. There are items in the field that are comma separated, so I don't want to remove them, just the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.