Hi I have the following regular expression in JavaScript:
var re = new RegExp("\\[(\\d{8})([,|;]\\s*\\d{8})*\\]", "g");
When I set variables to equal the first and last bracket (with escape characters), which I get from attributes of an element and pass those variables to RegExp like this:
HTML:
div id="myid" left="\\[" right="\\]"/>
JavaScript:
bs = $("#myid");
left = bs.attr('left');
right = bs.attr('right');
var re = new RegExp(left + "(\\d{8})([,|;]\\s*\\d{8})*" + right, "g");
I get the error message:
Uncaught SyntaxError: Invalid regular expression: /\\[(\d{8})([,|;]\s*\d{8})*\\]/: Unmatched ')'
What am I doing wrong here?
Thanks