JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://rawgit.com/icodeforlove/node-balanced/master/dist/balanced-min.js"></script>

JavaScript

function getLast(string) {
    return balanced.matches({ source: string, open: '(', close: ')'
    }).map(function (match) { return string.substr(match.index + match.head.length, match.length - match.head.length - match.tail.length); }).filter(function (a,b,c) { return b===c.length-1; })[0] || "Not balanced";
}

document.getElementsByTagName('body')[0].innerHTML += getLast("This is a test string to illustrate the problem (example) in complex matching logic (Work / not working (in this case) to match this last occurring bracket closure)") + '<hr/>';

document.getElementsByTagName('body')[0].innerHTML += getLast("Simpler version of the string (Matchable in any easy way)") + '<hr/>';

document.getElementsByTagName('body')[0].innerHTML += getLast("Simpler ve(rsion) of the string (Matchab(le (in) any) easy way)") + '<hr/>';

document.getElementsByTagName('body')[0].innerHTML += getLast("Simpler version of the string (Matc(hable in any easy way)") + '<hr/>';