开发者

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:

  1. The actual regex too complex (not in your case, as you only have /_ID/)
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜