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

Removing wild characters from a string

P: n/a
hi

I am tring to remove all the wild characters from a string. Is there
any short method to remove them in a single go.

I am right now tring to replace one by one.

Ex (999) 999-9999

I need 9999999999 with out all the charecters and spaces. I am trying
eliminate one by one now.

If you have any other ideas please post it

Thank You,
Satish

Nov 29 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I don't know if this is the best solution, but you can loop through
character by character, examine each one, and if it is a digit, add it to a
brand new string. After you are done, the new string will have only the
digits.

"SatishPasala" <ps***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
hi

I am tring to remove all the wild characters from a string. Is there
any short method to remove them in a single go.

I am right now tring to replace one by one.

Ex (999) 999-9999

I need 9999999999 with out all the charecters and spaces. I am trying
eliminate one by one now.

If you have any other ideas please post it

Thank You,
Satish

Nov 29 '05 #2

P: n/a
Learn Regular Expressions. They can be used for updating strings as well as
searching...

You can accomplish in just a couple of lines of code (with Regular
Expressions) what would otherwise require many many lines of code in a
looping approach that builds a new string from the old OR uses
StringBuilder...

-HTH
"SatishPasala" <ps***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
hi

I am tring to remove all the wild characters from a string. Is there
any short method to remove them in a single go.

I am right now tring to replace one by one.

Ex (999) 999-9999

I need 9999999999 with out all the charecters and spaces. I am trying
eliminate one by one now.

If you have any other ideas please post it

Thank You,
Satish

Nov 29 '05 #3

P: n/a
From the server-side add on top of the codebehind:
using System.Text.RegularExpressions;

Then in the body of the function

//a pattern to find non word characters
Regex re = new Regex ("[^\\w]+");
//replace the matched pattern
Response.Write (re.Replace("(99)@3-87-9%!~(9175)", ""));
//should print 9938799175
If you are doing it using Javascript on the client-side:
alert("(99)@3-87-9%!~(9175)".replace(/[^\w]+/g,""));
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"SatishPasala" wrote:
hi

I am tring to remove all the wild characters from a string. Is there
any short method to remove them in a single go.

I am right now tring to replace one by one.

Ex (999) 999-9999

I need 9999999999 with out all the charecters and spaces. I am trying
eliminate one by one now.

If you have any other ideas please post it

Thank You,
Satish

Nov 29 '05 #4

P: n/a
The regular expression worked really good. thank Phillip

Thank you guys for the help.
satish

Nov 29 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.