I am trying to replace the string {NUM} in the following variable:
var table = '        <table class="full-width">\r\n' +
            '            <tbody>\r\n' +
            '            <tr>\r\n' +
            '                <td width="75%" class="border-right-dotted left-line-tab">\r\n' +
            '                    <span id="47_TOTAL-CHARGES_D_{NUM}" class="input-text"></span>\r\n' +
            '                </td>\r\n' +
            '                <td width="25%" class="center-text">\r\n' +
            '                    <span id="47_TOTAL-CHARGES_C_{NUM}" class="input-text"></span>\r\n' +
            '                </td>\r\n' +
            '            </tr>\r\n' +
            '            </tbody>\r\n' +
            '        </table>\r\n';
using the following jquery replace:
table = table.replace("/{NUM}/gm", num);
but it doesn't seem to work. Testing the regex in https://regex101.com/ seems to present that the regex is fine, but it still does not replace the text as expected.

 
    