JSFiddle - React, Tailwind, and code Playground

HTML

<div id='myDiv'>
    This is the semi-inner text
    <div id='other'></div>
    This is the semi-inner text
<div>

<button>replace</button>

CSS

#other{
  background-color:grey;
  height:1px;
}

JavaScript

$(document).ready(function() {
    
  $("button").click(function(){
        
    target_div = $("#myDiv")
      reg_exp  = /This is the semi-inner text/g;
      new_text = "some other text"
        
      target_div.html(
        target_div.html()
          .replace(
            new RegExp(reg_exp),
            new_text)
            ); 
     });
    
});