JSFiddle - React, Tailwind, and code Playground

HTML

<h1>ThisVeryLongWord</h1>

JavaScript

$("h1").html($("h1").text().replace(/([^\s-]{5})(?=[^\s-])/g, '$1&shy;'));