{"_id":"safe-regex2","_rev":"4251967","name":"safe-regex2","description":"detect possibly catastrophic, exponential-time regular expressions","dist-tags":{"latest":"5.1.0"},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"time":{"modified":"2026-03-31T23:47:37.000Z","created":"2019-02-18T05:40:35.761Z","5.1.0":"2026-03-12T16:55:56.170Z","5.0.0":"2025-03-08T16:37:11.509Z","4.0.1":"2024-12-30T13:27:34.583Z","4.0.0":"2024-07-12T12:25:13.129Z","3.1.0":"2022-12-04T23:58:26.378Z","3.0.0":"2022-05-25T10:30:14.103Z","2.0.0":"2019-02-18T05:40:35.761Z"},"users":{},"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex2.git"},"versions":{"5.1.0":{"name":"safe-regex2","version":"5.1.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","type":"commonjs","types":"types/index.d.ts","bin":{"safe-regex2":"bin/safe-regex2.js"},"dependencies":{"ret":"~0.5.0"},"devDependencies":{"c8":"^11.0.0","eslint":"^9.17.0","neostandard":"^0.12.0","tsd":"^0.33.0"},"scripts":{"lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 --100 node --test"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex2.git"},"bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"homepage":"https://github.com/fastify/safe-regex2","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Gürgün Dayıoğlu","email":"hey@gurgun.day","url":"https://heyhey.to/G"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","gitHead":"96f8f0a42e1ff0b7ca7f57cb9990d9bf0cff0aa1","_id":"safe-regex2@5.1.0","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"shasum":"758fd224d066f5abe24f67bd574a01c9dd447f51","size":4760,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-5.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-5.1.0.tgz"},"_npmUser":{"name":"fdawgs","email":"frazer.dev@icloud.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-regex2_5.1.0_1773334556032_0.45691149042897017"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-03-12T16:55:56.170Z","publish_time":1773334556170,"_source_registry_name":"default","_cnpm_publish_time":1773334556170},"5.0.0":{"name":"safe-regex2","version":"5.0.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","type":"commonjs","types":"types/index.d.ts","dependencies":{"ret":"~0.5.0"},"devDependencies":{"@fastify/pre-commit":"^2.1.0","c8":"^10.1.3","eslint":"^9.17.0","neostandard":"^0.12.0","tape":"^5.7.5","tsd":"^0.31.0"},"scripts":{"lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex2.git"},"bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"homepage":"https://github.com/fastify/safe-regex2","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Gürgün Dayıoğlu","email":"hey@gurgun.day","url":"https://heyhey.to/G"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","_id":"safe-regex2@5.0.0","gitHead":"eae408949fc25eb165284316c2b1062741dfc91f","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"shasum":"762e4a4c328603427281d2b99662f2d04e4ae811","size":4228,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-5.0.0.tgz"},"_npmUser":{"name":"fdawgs","email":"frazer.dev@icloud.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-regex2_5.0.0_1741451831270_0.5975767791091413"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-08T16:37:11.509Z","publish_time":1741451831509,"_source_registry_name":"default","_cnpm_publish_time":1741451831509},"4.0.1":{"name":"safe-regex2","version":"4.0.1","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","type":"commonjs","types":"types/index.d.ts","dependencies":{"ret":"~0.5.0"},"devDependencies":{"@fastify/pre-commit":"^2.1.0","c8":"^10.1.3","eslint":"^9.17.0","neostandard":"^0.12.0","tape":"^5.7.5","tsd":"^0.31.0"},"scripts":{"lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex2.git"},"bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"homepage":"https://github.com/fastify/safe-regex2","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Gürgün Dayıoğlu","email":"hey@gurgun.day","url":"https://heyhey.to/G"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","_id":"safe-regex2@4.0.1","gitHead":"ba5c2ed862ac209ae4abc158784a69df46354384","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"shasum":"b0a4b0216c1dd0256af987b7aea473e1c91543a8","size":4244,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-4.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-4.0.1.tgz"},"_npmUser":{"name":"fdawgs","email":"frazer.dev@icloud.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-regex2_4.0.1_1735565254414_0.8321911678517726"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-12-30T13:27:34.583Z","publish_time":1735565254583,"_source_registry_name":"default","_cnpm_publish_time":1735565254583},"4.0.0":{"name":"safe-regex2","version":"4.0.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","type":"commonjs","types":"types/index.d.ts","dependencies":{"ret":"~0.5.0"},"devDependencies":{"@fastify/pre-commit":"^2.1.0","c8":"^7.14.0","standard":"^17.1.0","tape":"^5.7.5","tsd":"^0.31.0"},"scripts":{"lint":"standard","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex.git"},"homepage":"https://github.com/fastify/safe-regex","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"}],"license":"MIT","_id":"safe-regex2@4.0.0","gitHead":"90e7177a45e993203898398c77b2f087d1dc23d8","bugs":{"url":"https://github.com/fastify/safe-regex/issues"},"_nodeVersion":"20.15.0","_npmVersion":"10.7.0","dist":{"shasum":"5e04d8362cd4884753c8bce9715d4759a5239c0a","size":3837,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-4.0.0.tgz"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex2_4.0.0_1720787112994_0.7491400192400415"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-07-12T12:25:13.129Z","publish_time":1720787113129,"_source_registry_name":"default","_cnpm_publish_time":1720787113129},"3.1.0":{"name":"safe-regex2","version":"3.1.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","types":"types/index.d.ts","dependencies":{"ret":"~0.4.0"},"devDependencies":{"standard":"^17.0.0","tape":"^5.0.0","tsd":"^0.25.0"},"scripts":{"lint":"standard","test":"npm run test:unit","test:typescript":"tsd","test:unit":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex.git"},"homepage":"https://github.com/fastify/safe-regex","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"}],"license":"MIT","gitHead":"e9861278253e00f4b9868ef403d6852d0ac53307","bugs":{"url":"https://github.com/fastify/safe-regex/issues"},"_id":"safe-regex2@3.1.0","_nodeVersion":"16.17.0","_npmVersion":"9.1.2","dist":{"shasum":"fd7ec23908e2c730e1ce7359a5b72883a87d2763","size":3633,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-3.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex2_3.1.0_1670198306219_0.2729882832525603"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-04T23:58:29.698Z","publish_time":1670198306378,"_cnpm_publish_time":1670198306378},"3.0.0":{"name":"safe-regex2","version":"3.0.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","dependencies":{"ret":"~0.4.0"},"devDependencies":{"standard":"^17.0.0","tape":"^5.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex.git"},"homepage":"https://github.com/fastify/safe-regex","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"}],"license":"MIT","gitHead":"77f3de04dc2744a50f53a315772dbd60d63b9799","bugs":{"url":"https://github.com/fastify/safe-regex/issues"},"_id":"safe-regex2@3.0.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"822e04bed41d564024be55c3338eeb38c9d27aa5","size":3261,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-3.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex2_3.0.0_1653474613933_0.325470533541957"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-25T12:27:36.622Z","publish_time":1653474614103,"_cnpm_publish_time":1653474614103},"2.0.0":{"name":"safe-regex2","version":"2.0.0","description":"detect possibly catastrophic, exponential-time regular expressions","main":"index.js","dependencies":{"ret":"~0.2.0"},"devDependencies":{"standard":"^12.0.1","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git://github.com/fastify/safe-regex.git"},"homepage":"https://github.com/fastify/safe-regex","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"}],"license":"MIT","gitHead":"6af6b35b1609474d928a5e9a8af4f95ab6771628","bugs":{"url":"https://github.com/fastify/safe-regex/issues"},"_id":"safe-regex2@2.0.0","_nodeVersion":"10.15.1","_npmVersion":"6.7.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"b287524c397c7a2994470367e0185e1916b1f5b9","size":2778,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-regex2/download/safe-regex2-2.0.0.tgz"},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fdawgs","email":""},{"name":"gurgunday","email":""},{"name":"ivan-tymoshenko","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-regex2_2.0.0_1550468435646_0.20697473603543237"},"_hasShrinkwrap":false,"publish_time":1550468435761,"_cnpm_publish_time":1550468435761}},"readme":"# safe-regex2\n\n[![CI](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/safe-regex2.svg?style=flat)](https://www.npmjs.com/package/safe-regex2)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDetect potentially [catastrophic](http://regular-expressions.mobi/catastrophic.html) [exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)\nregular expressions by limiting the [star height](https://en.wikipedia.org/wiki/Star_height) to 1.\n\nThis is a fork of https://github.com/substack/safe-regex at 1.1.0.\n\nWARNING: This module has both false positives and false negatives.\nIt is not meant as a full checker, but it detects basic cases.\n\n## Install\n```sh\nnpm i safe-regex2\n```\n\n## Usage via npx\n\nYou can use this module via `npx` without installing it globally:\n\nExample:\n```sh\nnpx safe-regex2 '(x+x+)+y'\n```\n\n## Example\n\n``` js\nconst safe = require('safe-regex2');\nconst regex = process.argv.slice(2).join(' ');\nconsole.log(safe(regex));\n```\n\n```\n$ node safe.js '(x+x+)+y'\nfalse\n$ node safe.js '(beep|boop)*'\ntrue\n$ node safe.js '(a+){10}'\nfalse\n$ node safe.js '\\blocation\\s*:[^:\\n]+\\b(Oakland|San Francisco)\\b'\ntrue\n```\n\n## Methods\n\n``` js\nconst safe = require('safe-regex')\n```\n\n### const ok = safe(re, opts={})\n\nReturns a boolean indicating whether the regex `re` is safe\nand not possibly catastrophic.\n\n`re` can be a `RegExp` object or just a string.\n\nIf `re` is a string and is an invalid regex, it returns `false`.\n\n* `opts.limit` - maximum number of allowed repetitions in the entire regex.\nDefault: `25`.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","_attachments":{},"homepage":"https://github.com/fastify/safe-regex2","bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"license":"MIT"}