I am looking to wrap the first word in a string, for example:
var html = '<br> <br> Hello world!';
I have the following code:
html.replace(/^\s*\w+/, '<div class="underline">$&</div>');
This will output:
<div class="underline"><br></div> <br> Hello world!
How can I ignore HTML tags so that the output is like this, where the first word "Hello" gets wrapped in the DIV?:
<br> <br> <div class="underline">Hello</div> world!