Javascript String camelToDash(str)

Description

Javascript String camelToDash(str)


String.prototype.camelToDash = function (str) {
    if(str == undefined) {
        str = this;//from  w ww.j a  v  a 2 s. c  o  m
    }
    return str.replace(/\W+/g, '-')
        .replace(/([a-z\d])([A-Z])/g, '$1-$2').toLowerCase();
}



PreviousNext

Related