By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

Remove unwanted charcters from a string

P: n/a
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 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.