When working with the following JavaScript code...
$.post(url, data, function (json) {
var patt = new RegExp('/^\[{"dID":/');
if (patt.test(json)) {
//output json results formatted
} else {
//error so output json string
$('#diaryTable').replaceWith(json);
}
}, 'json');
My JSON is supposed to be either a valid JSON that starts with
[{"dID":
or it will have the format
[{ followed by an ex.Message from try catch exception... }]
However, I encounter the error message JavaScript runtime error: Expected ']' in regular expression
I tested my RegEx /^[{"dID":/ on RegEx101.com with sample data and it worked correctly. Any suggestions or insights?