views:

22

answers:

1
searchVersion: function (dataString) {
    var index = dataString.indexOf(this.versionSearchString);
    if (index == - 1) return;
    return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
}

... returns browser version, in my case, its "3.6". Since I'm going to use this as a class name, I want to remove any special chars including the "." in it, or replace it with an "-" or "_" and lowercase everything. Want to sanitize is basically.

Thanks!

+2  A: 
"3.6".replace(/\W/g,"_")
3_6

\W - any character except A-Za-z0-9_

UPDATE:

"Firefox/3.6".replace(/\W/g,"_").toLowerCase()
firefox_3_6
S.Mark