JSFiddle - React, Tailwind, and code Playground JavaScript var re=/\((\d{3})\)/g; var p='(555)666-1212'.replace(re,'$1-'); console.log(p)