JSFiddle - React, Tailwind, and code Playground

by Nick Craver

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">

JavaScript

var a = "This is an A B pattern: ABABA";  
a = a.replace(/(A|B)/g, function(a, m) { return m == "A" ? "B" : "A"; });
alert(a);