JSFiddle - React, Tailwind, and code Playground JavaScript var text = "FirstName"; var newText = text.replace(/([A-Z])[a-z]*$/,"$1"); alert(newText);