Don't use regular expression to parse HTML, use an HTML parser to parse HTML. Your browser already has one built in for you to use:
let code = `<div>\\frac{5}{6}</div>`;
let doc = new DOMParser().parseFromString(code, `text/html`)
let content = doc.querySelector(`div`).textContent
But of course, note that your string is missing a \
:
"\\f"
in a string declaration is a slash, and then the letter f
"\f"
in a string declaration is the FORM FEED
control code (\u000c
)
If your string came "from somewhere" then make sure to properly escape your content before you start to work with it. For example, if this is user input and you composed it, like:
let text = `<div>${input.value}</div>`;
then: make sure to escape that value before you template it in.