JSFiddle - React, Tailwind, and code Playground

by avrelian

HTML

<input id="input" value="I'm [b]strong[/b]" />
And I'm [b]not[b]
<input type="button" id="button" value="Who is strong?" />
<div id="result"></div>

CSS

strong { font-size: 150%; }

JavaScript

$(document).ready(function(){
    $('#button').click(function(){
        text = $('#input').val();
        text = text.replace(new RegExp('(^|\\s|>)\\[b](\\S.*?\\S)\\[/b]($|\\s|<)', 'im') , '$1<strong>$2</strong>$3');
        $('#result').html(text);
    });
});