JSFiddle - React, Tailwind, and code Playground
HTML
<p class="regex">Text before http://bit.ly/wtGAhsu sometext here</p>
<p class="regex">http://bit.ly/wtGAhsu sometext here</p>
<p class="regex">Text before http://bit.ly/wtGAhsu</p>
<p class="regex">Text before http://bit.ly/666 blah</p>
<p class="no_regex">No regex on this p. http://bit.ly/4444 sometext here</p>
CSS
.regex span {
background: yellow;
margin-left: 1em;
}
JavaScript
$("p.regex").each ( function () {
var jThis = $(this);
var newSrc = jThis.text ().replace (/^(.*)(https?\:\/\/bit\.ly\/\w+)(.*)$/i, '$1$3<span>$2</span>');
jThis.html (newSrc);
} );