July 15, 2008

ReplaceAll in Javascript

Nikolai Kordulla


In javascript you only have replace. If you want to use replaceall just do this.
string.replace(/\W+/g, '-');
The g stands for ReplaceAll. So in this case all non word characters will be replaced with '-'.



Leave a Reply

Don't enter anything here:
Name (required) Invalid name
Mail (will not be published) (required) Invalid mail
Website Invalid url

Content couldnt be empty.