Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Remove unwanted charcters from a string

Reply
Thread Tools

Remove unwanted charcters from a string

 
 
Chris Kettenbach
Guest
Posts: n/a
 
      07-20-2005
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


 
Reply With Quote
 
 
 
 
Chris Kettenbach
Guest
Posts: n/a
 
      07-20-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accented charcters in Asp.net charvind ASP .Net 0 08-13-2008 04:51 PM
ASP.NET 2.0 TextBOx WildCard charcters ABHIJIT B ASP .Net 0 02-20-2008 04:54 PM
Remove newline charcters froma string peelman ASP .Net 1 10-18-2005 05:21 PM
Control charcters in form input field Paul Jørstad Javascript 4 09-19-2003 08:01 PM
charcters styles via html brandons of mass destruction XML 1 07-30-2003 07:34 PM



Advertisments