Encapsulate results in div tags I would like to turn the following:

&lt;div&gt;this is a $test&lt;/div&gt;


into

&lt;div&gt;this is a &lt;div&gt;$test&lt;/div&gt;&lt;/div&gt;


currently I have 

var regexp = new RegExp('$([^\\s]*)','g'),
    html = '&lt;div&gt;this is a $test&lt;/div&gt;',
    matched = html.match(regexp)[0]

if (matched){
   html = html.replace(match, '&lt;div&gt;' + match + '&lt;/div&gt;')
}


which works, but is there a more concise way of doing this?
Sure, use String.replace. As an added bonus, it doesn't fail when there is no match:

'&lt;div&gt;this is a $test&lt;/div&gt;'.replace(/(\$\w+)/g, '&lt;div&gt;$1&lt;/div&gt;')