182
rated 0 times
[
185]
[
3]
/ answers: 1 / hits: 154369
/ 12 Years ago, mon, october 22, 2012, 12:00:00
I want to remove all special characters and spaces from a string and replace with an underscore.
The string is
var str = hello world & hello universe;
I have this now which replaces only spaces:
str.replace(/s/g, _);
The result I get is hello_world_&_hello_universe
, but I would like to remove the special symbols as well.
I tried this str.replace(/[^a-zA-Z0-9]s/g, _)
but this does not help.
More From » javascript