JSFiddle - React, Tailwind, and code Playground

by Andres Arrieche

HTML

<p id="demo">@[andres arrieche](some:thing) andres arrieche y andres arrieche</p>

<button id="try">Try it</button>

JavaScript

$("#try").click(function(){
    var str = $("#demo").html();
    var sustituto="@[andres arrieche](some:thing)"
    var res = str.replace(/\[.*?\]|(andres arrieche)/gi, sustituto);
    document.getElementById("demo").innerHTML = res;
})

/*
I need "@[andres arrieche](some:thing) andres arrieche y andres arrieche"
change to

"@[andres arrieche](some:thing) @[andres arrieche](some:thing) y @[andres arrieche](some:thing)"
*/