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

String sent to function, needs to return only alphanumeric values

P: 19
Hey everyone, I had a quick problem:

I want to be able to send a string of data to a function and have it return that same string but only in alphanumerics. That is to say, if I sent it:

"Hello world 1!"

It should return:

"Helloworld1"

Is this possible? I know I can do a verification using RegEx, but I want to actually alter the string to return only alphanumeric. Any help would be much appreciated!

MGM out
Apr 16 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 428
You can use the same RegExp pattern to replace as well as to test-

string=string.replace(/\W+/g,'');
Apr 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.