ECMA 262 12 Lexical Grammer

8 Literals

8.5 Regular Expression Literals

A regular expression literal is an input element that is converted to a RegExp object (see 22.2) each time the literal is evaluated. Two regular expression literals in a program evaluate to regular expression objects that never compare as === to each other even if the two literals’ contents are identical. A RegExp object may also be created at runtime by new RegExp or calling the RegExp constructor as a function (see 22.2.3).

下面的productions描述了regular expression literal的语法 and are used by the input element scanner to find the end of the regular expression literal. The source text comprising the RegularExpressionBody and the RegularExpressionFlags are subsequently parsed again using the more stringent ECMAScript Regular Expression grammar (22.2.1).

An implementation may extend the ECMAScript Regular Expression grammar defined in 22.2.1, but it must not extend the RegularExpressionBody and RegularExpressionFlags productions defined below or the productions used by these productions.

语法

R e g u l a r E x p r e s s i o n L i t e r a l : : / R e g u l a r E x p r e s s i o n B o d y / R e g u l a r E x p r e s s i o n F l a g s RegularExpressionLiteral::\\\qquad / \enspace RegularExpressionBody\enspace / \enspace RegularExpressionFlags RegularExpressionLiteral::/RegularExpressionBody/RegularExpressionFlags

R e g u l a r E x p r e s s i o n B o d y : : R e g u l a r E x p r e s s i o n F i r s t C h a r R e g u l a r E x p r e s s i o n C h a r s RegularExpressionBody::\\\qquad RegularExpressionFirstChar \enspace RegularExpressionChars RegularExpressionBody::RegularExpressionFirstCharRegularExpressionChars

R e g u l a r E x p r e s s i o n C h a r s : : [empty] R e g u l a r E x p r e s s i o n C h a r s R e g u l a r E x p r e s s i o n C h a r RegularExpressionChars::\\ \qquad \text{[empty]} \\\qquad RegularExpressionChars\enspace RegularExpressionChar RegularExpressionChars::[empty]RegularExpressionCharsRegularExpressionChar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值