JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<span>test1 test1 test1 test1 test1 test1 test1</span></br>
<span>test2 test2 test2 test2 test2 test2 test2</span></br>
<span>test3 test3 <span class="target">[test3 test3]</span> test3 test3 test3</span></br>
<span>test4 <span class="target">[test4 test4 test4 test4]</span> test4 test4</span></br>
<span>test5 test5 test5 test5 test5 test5 test5</span></br>
CSS
.marked{
background-color:blue;
font-weight: bold;
color:white;
}
JavaScript
$(function() {
$(".target").each(function(){
var str = $(this).text();
str = str.replace(/[[\]]/g, "");
$(this).addClass("marked").text(str);
})
})