I'm unfamiliar with regex and can't figure out how to join two expressions
for example i have a slug and I want to prepend a /
and replace spaces with hyphens
replace(/^/, '/' && /\s /g, '-')
CodePudding user response:
Why don't you simply chain the replace ?
str.replace(/^/, '/').replace(/\s /g, '-')