{"id":15653231,"url":"https://github.com/silverwind/cidr-regex","last_synced_at":"2025-04-05T21:10:42.444Z","repository":{"id":57198776,"uuid":"54639537","full_name":"silverwind/cidr-regex","owner":"silverwind","description":"Regular expression for matching IP addresses in CIDR notation","archived":false,"fork":false,"pushed_at":"2024-04-13T18:55:15.000Z","size":324,"stargazers_count":29,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T08:56:35.593Z","etag":null,"topics":["cidr","ip","javascript","module","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silverwind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-24T12:16:29.000Z","updated_at":"2024-06-18T13:54:08.370Z","dependencies_parsed_at":"2023-01-28T14:47:44.525Z","dependency_job_id":"43bab20c-9827-471e-af4f-60432a8a403d","html_url":"https://github.com/silverwind/cidr-regex","commit_stats":{"total_commits":80,"total_committers":4,"mean_commits":20.0,"dds":"0.16249999999999998","last_synced_commit":"c13387acf04558ee103dd20cc24551beb8b8b142"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fcidr-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fcidr-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fcidr-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fcidr-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silverwind","download_url":"https://codeload.github.com/silverwind/cidr-regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399885,"owners_count":20932880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","ip","javascript","module","nodejs"],"created_at":"2024-10-03T12:45:03.846Z","updated_at":"2025-04-05T21:10:42.398Z","avatar_url":"https://github.com/silverwind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cidr-regex\n[![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex) [![](https://packagephobia.com/badge?p=cidr-regex)](https://packagephobia.com/result?p=cidr-regex)\n\n\u003e Regular expression for matching IP addresses in CIDR notation\n\n## Usage\n\n```sh\n$ npm i cidr-regex\n```\n\n```js\nimport cidrRegex from \"cidr-regex\";\n\n// Contains a CIDR IP address?\ncidrRegex().test(\"foo 192.168.0.1/24\");\n//=\u003e true\n\n// Is a CIDR IP address?\ncidrRegex({exact: true}).test(\"foo 192.168.0.1/24\");\n//=\u003e false\n\ncidrRegex.v6({exact: true}).test(\"1:2:3:4:5:6:7:8/64\");\n//=\u003e true\n\n// Extract CIDRs from string\n\"foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz\".match(cidrRegex());\n//=\u003e [\"192.168.0.1/24\", \"1:2:3:4:5:6:7:8/64\"]\n```\n\n## API\n### cidrRegex([options])\n\nReturns a regex for matching both IPv4 and IPv6 CIDR IP addresses.\n\n### cidrRegex.v4([options])\n\nReturns a regex for matching IPv4 CIDR IP addresses.\n\n### cidrRegex.v6([options])\n\nReturns a regex for matching IPv6 CIDR IP addresses.\n\n#### options.exact\n\nType: `boolean`\u003cbr\u003e\nDefault: `false` *(Matches any CIDR IP address in a string)*\n\nOnly match an exact string. Useful with `RegExp#test()` to check if a string is a CIDR IP address.\n\n## Related\n\n- [ip-bigint](https://github.com/silverwind/ip-bigint) - Convert IPv4 and IPv6 addresses to native BigInt and vice-versa\n- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses\n- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation\n- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address\n- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists\n\n## License\n\n© [silverwind](https://github.com/silverwind), distributed under BSD licence\n\nBased on previous work by [Felipe Apostol](https://github.com/flipjs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fcidr-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilverwind%2Fcidr-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fcidr-regex/lists"}