Ruby - USA State PORO
A simple PORO that represents a USA state.
A simple PORO that represents a USA state.
const parameterize = string =>
string
.toLowerCase()
.replace(/[^a-zA-Z0-9 -]/g, ' ') // convert unwanted chars to spaces
.replace(/\s\s+/g, ' ') // convert multi spaces to single space
.replace(/\s/g, '-') // convert spaces to hyphens
.replace(/--+/g, '-') // convert multi hyphens to single hyphen
parameterize('Masatoshi Nishiguchi::web developer')
parameterize('Masatoshi Nishiguchi, web developer')
parameterize('Masatoshi Nishiguchi -- web developer')
//=> "masatoshi-nishiguchi-web-developer"