JSFiddle - React, Tailwind, and code Playground

by unilecs

JavaScript

const title = 'Some text ** New    Title    **  Some text';

console.log(title.replace(/(\*\*)\s{0,}((\w+\s+){1,}\w+)(\s+)?\1/, '**$2**'));