JSFiddle - React, Tailwind, and code Playground JavaScript var str = 'hello/page/2/bye'; str = str.replace(/page\/\d+\//,''); alert(str);