After consulting the ECMAScript spec, I wrote a (JavaScript) RegExp that matches only valid identifiers, keywords and reserved words:
/^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u
This will be much harder to do without the u flag, as ID_Start and ID_Continue are very complicated. They are defined in the Unicode Character Database’s DerivedCoreProperties.txt (Ctrl+F for “Derived Property: ID_Start”)