Error in Firefox while replace string using regexp in JavaScript
try{
var hdnPassenger = $("#ctl00_ContentPlaceHolder1_hdnPassenger").val();
var newTr = $("#hdnCtl").html();
newTr = newTr.replace(/_ID/g, hdnPassenger);
}
catch(ex){
alert(ex);
}
Above code is work开发者_Go百科ing fine in the internet explorer, but displayed the following error in the mozilla firefox
InternalError: regular expression too complex
Having done some research into this problem, there are two possible reasons for this error:
- The actual regex too complex (not in your case, as you only have /_ID/)
- The length of the string you're trying to do the substitution on (I don't know what it is, but probably quite long). It seems that there's some hard-coded limit in some versions of firefox, but I can't vouch for that.
I suggest you do two this: add the values of your hdnPassenger
and newTr
variables - and at the same time google firefox regular expression too complex
- there are plenty of hits.
精彩评论