JSFiddle - React, Tailwind, and code Playground JavaScript var a='some thing [0] [1] [0] [1] '; a = a.replace(/\[\d\]/g, 'new'); alert(a);