JSFiddle - React, Tailwind, and code Playground JavaScript var str = '/hello/world/test'; alert(str.slice(1).replace(/\//g, '-'));