Written by:David Aldridge
4/15/2011 2:02 PM 

I needed to be able to strip characters out of a string in javascript, so I came up with using the split and join methods:

mystring = mystring.split(' ').join('');

This would remove the spaces from the string mystring.

This can be combined to remove differing characters - say you wanted to remove spaces and dashes:

mystring = (mystring.split(' ').join('')).split('-').join('');



Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
You must be logged in and have permission to create or edit a blog.