Generating a regular expression to match valid JavaScript identifiers

View the source code to see how it’s done exactly. (A Node.js version of this script is also available.) This page combines the following resources and tools:

Note that the generated regular expressions don’t account for Unicode escape sequences in the identifier, so be sure to unescape those before validating.

Fun fact: comparing the output for ES 5.1 and ES 6 exposed a potential compatibility hazard.

ECMAScript 5.1 / Unicode v8.0.0

Loading resources…

ECMAScript 6 / Unicode v8.0.0

Loading resources…