{"_id":"identifier-regex","_rev":"4444482","name":"identifier-regex","description":"Regular expression for matching JavaScript identifiers","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-08T14:16:50.000Z","created":"2024-05-05T18:14:08.435Z","1.0.1":"2025-09-13T10:37:21.783Z","1.0.0":"2024-05-05T18:14:08.435Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/identifier-regex.git"},"versions":{"1.0.1":{"name":"identifier-regex","version":"1.0.1","description":"Regular expression for matching JavaScript identifiers","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/identifier-regex.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["identifier","regex","regexp","regular","expression","keyword","word","reserved","javascript","ecmascript"],"dependencies":{"reserved-identifiers":"^1.0.0"},"devDependencies":{"ava":"^6.1.2","xo":"^0.58.0"},"_id":"identifier-regex@1.0.1","gitHead":"2d400947acd1c05dd85108dc2e35d32f68ec53d8","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/identifier-regex/issues"},"homepage":"https://github.com/sindresorhus/identifier-regex#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"shasum":"65fc1c16eebad54adcbec7eb9c99e8a926adfd29","size":2185,"noattachment":false,"key":"/identifier-regex/-/identifier-regex-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/identifier-regex/download/identifier-regex-1.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/identifier-regex_1.0.1_1757759841592_0.11715930482953874"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-13T10:37:21.783Z","publish_time":1757759841783,"_source_registry_name":"default","_cnpm_publish_time":1757759841783},"1.0.0":{"name":"identifier-regex","version":"1.0.0","description":"Regular expression for matching JavaScript identifiers","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/identifier-regex.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["identifier","regex","regexp","regular","expression","keyword","word","reserved","javascript","ecmascript"],"dependencies":{"reserved-identifiers":"^1.0.0"},"devDependencies":{"ava":"^6.1.2","xo":"^0.58.0"},"_id":"identifier-regex@1.0.0","gitHead":"03d68b126589b7e86a3c10c9c7c8d2e05cebf136","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/identifier-regex/issues"},"homepage":"https://github.com/sindresorhus/identifier-regex#readme","_nodeVersion":"20.12.2","_npmVersion":"10.6.0","dist":{"shasum":"b9fc92aecfe3d9f3b427fd5af0d2e663163fcbef","size":2158,"noattachment":false,"key":"/identifier-regex/-/identifier-regex-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/identifier-regex/download/identifier-regex-1.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/identifier-regex_1.0.0_1714932848282_0.543222216913434"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-05-05T18:14:08.435Z","publish_time":1714932848435,"_source_registry_name":"default","_cnpm_publish_time":1714932848435}},"readme":"# identifier-regex\n\n> Regular expression for matching valid [JavaScript identifiers](https://developer.mozilla.org/en-US/docs/Glossary/Identifier)\n\n## Install\n\n```sh\nnpm install identifier-regex\n```\n\n## Usage\n\n```js\nimport identifierRegex from 'identifier-regex';\n\nidentifierRegex().test('foo');\n//=> true\n\nidentifierRegex().test('1kg');\n//=> false\n\nidentifierRegex().test('await'); // Reserved identifier\n//=> false\n\n'@x $x #x'.match(identifierRegex({exact: false}));\n//=> ['$x']\n```\n\n> [!IMPORTANT]\n> If you run the regex against untrusted user input in a server context, you should [give it a timeout](https://github.com/sindresorhus/super-regex). I do not consider ReDoS a valid vulnerability for this package.\n\n> [!NOTE]\n> Although `globalThis`, `Infinity`, `NaN`, and `undefined` are [properties of the global object](https://tc39.es/ecma262/#sec-value-properties-of-the-global-object) and not identifiers, they are not matched by the regex because they should generally not be used as identifiers.\n\n## API\n\n### identifierRegex(options?)\n\nReturns a `RegExp` for matching valid JavaScript identifiers.\n\n#### options\n\nType: `object`\n\n##### exact\n\nType: `boolean`\\\nDefault: `true`\n\nOnly match an exact string.\n\n## Related\n\n- [is-identifier](https://github.com/sindresorhus/is-identifier) - Check if a string is a valid JavaScript identifier\n","_attachments":{},"homepage":"https://github.com/sindresorhus/identifier-regex#readme","bugs":{"url":"https://github.com/sindresorhus/identifier-regex/issues"},"license":"MIT"}