cidr-regex
Advanced tools
+25
-19
@@ -20,25 +20,31 @@ export type Options = { | ||
| /** | ||
| Regular expression for matching IP addresses in CIDR notation | ||
| declare const _default: { | ||
| @returns A regex for matching both IPv4 and IPv6 CIDRs. | ||
| /** | ||
| Regular expression for matching IP addresses in CIDR notation | ||
| @example | ||
| ``` | ||
| // Contains a CIDR IP address? | ||
| cidrRegex().test("foo 192.168.0.1/24"); | ||
| //=> true | ||
| @returns A regex for matching both IPv4 and IPv6 CIDRs. | ||
| // Is a CIDR IP address? | ||
| cidrRegex({exact: true}).test("foo 192.168.0.1/24"); | ||
| //=> false | ||
| @example | ||
| ``` | ||
| // Contains a CIDR IP address? | ||
| cidrRegex().test("foo 192.168.0.1/24"); | ||
| //=> true | ||
| cidrRegex.v6({exact: true}).test("1:2:3:4:5:6:7:8/64"); | ||
| //=> true | ||
| // Is a CIDR IP address? | ||
| cidrRegex({exact: true}).test("foo 192.168.0.1/24"); | ||
| //=> false | ||
| // Extract CIDRs from string | ||
| "foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz".match(cidrRegex()); | ||
| //=> ["192.168.0.1/24", "1:2:3:4:5:6:7:8/64"] | ||
| ``` | ||
| */ | ||
| export default function cidrRegex(options?: Options): RegExp; | ||
| cidrRegex.v6({exact: true}).test("1:2:3:4:5:6:7:8/64"); | ||
| //=> true | ||
| // Extract CIDRs from string | ||
| "foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz".match(cidrRegex()); | ||
| //=> ["192.168.0.1/24", "1:2:3:4:5:6:7:8/64"] | ||
| ``` | ||
| */ | ||
| (options?: Options): RegExp, | ||
| v4: typeof v4; | ||
| v6: typeof v6; | ||
| }; | ||
| export default _default; |
+1
-1
| { | ||
| "name": "cidr-regex", | ||
| "version": "4.0.4", | ||
| "version": "4.0.5", | ||
| "description": "Regular expression for matching IP addresses in CIDR notation", | ||
@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io>", |
5958
1.6%51
10.87%