简体   繁体   English

JS正则表达式代码不适用于Firefox,但适用于Chrome和IE

[英]JS regex code doesn't work with firefox, but works on chrome and IE

I'm having here a problem... (also not really a good js programmer, more a html/css person). 我在这里遇到问题...(也不是一个真正的js程序员,更不是一个html / css人)。 This code worked flawless before, but now it stopped working under firefox. 这段代码以前运行得很完美,但是现在在Firefox下停止了工作。 I have no clue why though... 我不知道为什么...

Its this line: 其这一行:

.replace(/((<li>(.*?)<\/li>){28})/g,'<ul>$1</ul>')

When I remove {28} it starts working again, but of course the script stops wrapping the li's in groups. 当我删除{28}时,它再次开始工作,但是脚本当然停止将li的分组包装。

Firefox only tells me this: an error occurred while executing regular expression Firefox仅告诉我这一点:执行正则表达式时发生错误

Maybe someone here had the same problem or an idea... 也许这里有人遇到相同的问题或想法...

Thanks! 谢谢!

The below regex would store the texts from <li> to </li> into a group, 下面的正则表达式会将<li></li>的文本存储到一个组中,

.replace(/(?:(<li>(.*?)<\/li>){28})/g,'<ul>$1</ul>')

Or if you want the text between <li> tags, then use the below regex, 或者,如果您想要<li>标记之间的文本,请使用以下正则表达式,

.replace(/(?:(?:<li>(.*?)<\/li>){28})/g,'<ul>$1</ul>')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript代码在chrome上有效,在IE和Firefox上无效 - JavaScript code works on chrome, doesn't work on IE and firefox 强制仅数字js函数在Firefox中不起作用,但在Chrome和IE中可以正常工作 - Force numeric only js function doesn't work in Firefox but in Chrome & IE works fine .unbind(&#39;submit&#39;)。submit()在Chrome / IE中有效,但在Firefox中无效 - .unbind('submit').submit() works in Chrome/IE but doesn't work in Firefox 该Javascript在IE中不起作用,但在Chrome,Firefox和Opera中起作用 - This Javascript doesn't work in IE but works in Chrome, Firefox and Opera jQuery模糊在Firefox和Chrome中不起作用,但在IE9中起作用 - Jquery blur doesn't work in Firefox and Chrome but works in IE9 Javascript不适用于Chrome和Firefox,但适用于IE - Javascript doesn't work on Chrome and Firefox, but works on IE EmberData unloadAll在IE8上不起作用。 适用于Chrome / FireFox - EmberData unloadAll doesn't work on IE8. Works on Chrome/FireFox JavaScript时钟可在Chrome上使用,但不适用于Firefox或IE - JavaScript clock works on Chrome but doesn't work with Firefox or IE Javascript 自动完成功能适用于 IE 和 Chrome,不适用于 Firefox - Javascript autocomplete works in IE and Chrome, doesn't work in Firefox 为什么此代码在FireFox和IE中不能使用,而在Chrome中不能使用? - Why Doesn't This Code Work in FireFox and IE but does in Chrome?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM