Remove unwanted charcters from a string

C

Chris Kettenbach

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
 
C

Chris Kettenbach

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
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top