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