JSFiddle - React, Tailwind, and code Playground

JavaScript

var a='some thing [0]  [1]  [0]  [1] ';
a = a.replace(/\[[0-2]\]/g,' new');
alert(a);