JSFiddle - React, Tailwind, and code Playground

by ZenMaster

HTML

<div id="result" style="padding: 10px;"></div>

JavaScript

var a = ':codedd/:code/*codeaa/*acode/*test/:test';
var data = { code: 'code1', acode : 'code2', test : 'test1'};
var str = '';
for(var prop in data) {
    str = new RegExp('[(:)(\\*)]\\b' + prop + '\\b([\/]?)', 'gi');
    a = a.replace(str, data[prop] + '$1');
}

$('#result').html(a);