JSFiddle - React, Tailwind, and code Playground

JavaScript

var o = { bob : 'is cool', steve : 'is not' };

retString = '[BOB] [STEVE] [BOB]';

for (n in o) {
  pattern = new RegExp('\\[' + n.toUpperCase() + '\\]', 'g');
  retString = retString.replace(pattern, o[n].toString());
}

alert(retString);