the format goal: require a.b.c.d/x where >>
- a is 1-3 digit num btw 1-223
- b, c, and d are 1-3 digit num btw 0-255 and *required
- x is 1 or 2 digit num btw 8-32 and the (/x) group is optional
here's the full regex I have now:
^(((?:22[0-3]|2([0-1])?\d?|([1-9][0-9]?|1[0-9]{2}))\.)((?:25[0-5]|2[0-4]\d|[01]?(\d{0,2}))\.){2}((25[0-5]|2[0-4]\d|[01]?(\d{0,2}))(\/([89]|[12]\d|3[0-2]))?),?\s?){1,50}$
**The problem I'm running into is: if "1.1.1." is entered (aka no 'd' group), it's passing validation. I want it to fail without the 'd' group **
here is the monstrosity broken into groups and w/ added spaces for my own sanity/readability: // start string, full group
^(
// a group, 1-223 with "."
((?:22[0-3]|2([0-1])?\d?|([1-9][0-9]?|1[0-9]{2}))\.)
// b and c groups 0-255 with "."
((?:25[0-5]|2[0-4]\d|[01]?(\d{0,2}))\.){2}
// d group, ends with optional netmask instead of "." // i tried making this non-optional as a group to solve my problem.
((25[0-5]|2[0-4]\d|[01]?(\d{0,2}))
// netmask
(\/([89]|[12]\d|3[0-2]))?)
// allow comma separated, optional space between, up to 50 IPs
,?\s?){1,50}$
(I'm realizing now that this comma is optional so they could split with only a space. Maybe I can prevent that too).