18
rated 0 times
[
19]
[
1]
/ answers: 1 / hits: 36248
/ 11 Years ago, tue, april 23, 2013, 12:00:00
I have a string where there may be special characters, which I have to replace with hyphen
var str=123.This is,, :ravi
The above string should be converted like this
var newstr=123-This-is-ravi;
I have been trying this
function remove(str){ str.replace(/./g, -); } //replaces only dots
function remove(str){ str.replace(/ /g, -); } //replaces only spaces
Can any one help me doing this? I need to replace special chars with hyphen.
More From » jquery