JavaScript:好的部分;为什么提前行不好? [英] JavaScript: The Good Parts; why is lookahead not good?

查看:82
本文介绍了JavaScript:好的部分;为什么提前行不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Douglas Crockfords JavaScript:好的部分,我刚刚完成了正则表达式一章.在本章中,他称JavaScript的\b,正向超前(?=)和负向超前(?!) 不是很好的部分"

I'm reading Douglas Crockfords Javascript: The Good Parts, I just finished the regular expressions chapter. In this chapter he calls JavaScript's \b, positive lookahead (?=) and negative lookahead (?!) "not a good part"

他解释了\b不好的原因(它使用\w进行单词边界查找,而\w对于使用Unicode字符的任何语言都失败),这对我来说似乎是一个很好的理由.

He explains the reason for \b being not good (it uses \w for word boundary finding, and \w fails for any language that uses unicode characters), and that looks like a very good reason to me.

不幸的是,忽略了正面和负面的前瞻性不好的原因,我无法提出一个理由. 掌握正则表达式向我展示了它的强大功能前瞻性(当然会解释它带来的问题),但是我真的想不出任何可以将其视为不好的部分"的东西.

Unfortunately, the reason for positive and negative lookahead being not good is left out, and I cannot come up with one. Mastering Regular Expressions showed me the power that comes with lookahead (and of course explains the issues it brings with it), but I can't really think of anything that would qualify it as "not a good part".

任何人都可以解释为什么通常认为JavaScript(正|负)前瞻或(正|负)前瞻吗?

似乎我不是唯一一个有以下问题的人:一个两个.

It seems I'm not the only one with this question: one and two.

推荐答案

也许是因为Internet Explorer的

Maybe it's because of Internet Explorer's perpetually buggy implementation of lookaheads. For anyone authoring a book about JavaScript, any feature that doesn't work in IE might as well not exist.

这篇关于JavaScript:好的部分;为什么提前行不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆