Javascript / Jquery. Substitute plain text with html using regular expression with wildcard
===

I want to replace the plain text (for example) [next 1272] with

    <a href='page.asp?id=1272'>
    <img src='next.png' alt='Next Page' title='Next Page' />
    </a>

The text could appear anywhere in the page html, and more than once, perhaps with a different number (from 1 to 99999). I don't have control of how/where it might appear.

Along the lines of

    var ThisBody = $("body").html()
    var regex = new RegExp("\\[  (I dont know) \\]", "g");
    StrToReplaceWith = "...(the html in the example, with correct number)..."
    ThisBody = ThisBody.replace(regex,StrToReplaceWith);
    $("body").html(ThisBody);	

PS I am very new to regular expressions in javascript. Many thanks