JSFiddle - React, Tailwind, and code Playground

HTML

<div id="assertion">
    Expected [foo] but Recieved [__]
</div>

JavaScript

var text = $("#assertion")
     .html()
     .replace( /(Expected \[)[^\]]*/,"fsd");

console.log(text);