JSFiddle - React, Tailwind, and code Playground

HTML

<div>here's a link to www.facebook.com: http://www.facebook.com/usernameone</div>
<div>here's another link to just facebook.com: http://facebook.com/username.two</div>
<button>Convert</button>

JavaScript

$(function()  {
     
  });
  
  $("button").click(function () {
      alert("Button clicked");
      var re = new RegExp("(http:\/\/(?:www\.)?facebook.com/)([^<]*)","gi");
     $("body").html($("body").html().replace(re, "<a href='$1$2' target='_blank'> $2 </a>"));
    });