JSFiddle - React, Tailwind, and code Playground

by Paulpro

JavaScript

var reg = /\bAB\b/g;
var str = 'ABABAB AB test AB aABb';
alert(str.replace(reg, '($0)'));