Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What ECMAScript implementations extend the RegExp syntax?

So I know in JavaScript an implementation is allowed to extend the regular expressions grammar:

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

Was this ability ever used? Do any existing JavaScript implementations extend the regular expressions grammar?

like image 981
Benjamin Gruenbaum Avatar asked Jun 20 '15 19:06

Benjamin Gruenbaum


People also ask

What is ECMAScript regex?

ECMAScript Regex is interpreted as any character, if you want it interpreted as a dot character normally required mark \ ahead. // Regex pattern describe any character. let regex1 = /./ ; // Regex pattern describe a dot character.

Which of the following syntax is correct for creating a RegExp object?

Syntax for creating a RegExp object: 1. var txt=new RegExp(pattern,attributes);

What flavor of regex does JavaScript use?

Using Regular Expressions with JavaScript. JavaScript's regular expression flavor is part of the ECMA-262 standard for the language.

Is Java and JavaScript regex same?

There is a difference between Java and JavaScript regex flavors: JS does not support lookbehind. A tabulation of differences between regex flavors can be found on Wikipedia. However, this does not apply to your case. I surmise that your JS test string has spurious characters, eg.


1 Answers

Yes, Mozilla's Gecko engine did support the sticky y flag, which was not part of ES5. It did eventually became part of ES6.

This ability may be utilised again when engines start implementing look-behind (I hope they start experimenting before it will get specced).

This is not an exhaustive list, just what first came to my mind. There may be other examples.

like image 120
Bergi Avatar answered Oct 21 '22 13:10

Bergi