JSFiddle - React, Tailwind, and code Playground JavaScript var str = "http://localhost/mysite/#portfolio/333"; alert(str.split('/').pop())