Skip to content

Instantly share code, notes, and snippets.

@ollyg
ollyg / cidr_to_regex.js
Last active December 18, 2024 08:07 — forked from radu-c/cidr_to_regex.js
const zip = (arr, ...arrs) => {
return arr.map((val, i) => arrs.reduce((a, arr) => [...a, arr[i]], [val]))
}
const cidrToRegex = cidr => {
const [ip, prefix] = cidr.split('/')
const base = ip
.split('.')
.map(val => parseInt(val))