JSFiddle - React, Tailwind, and code Playground JavaScript var str = "3xyz"; var str1 = str.replace(/([0-9]*)xyz/, "$10xyz"); alert(str1);