Re:Pattern Matching Without Regex – Introducing the Rosie Pa...
by samatman on Wednesday November 14, 2018 @02:23PM
(#18452978)
256 is either 1[0-9][0-9] or 2[0-5][0-6], for the three digit case; that which can be syntactically detected, should be.
[ Parent
| on HN ]
Re:Pattern Matching Without Regex – Introducing the Rosie Pa...
by diggernet on Wednesday November 14, 2018 @06:27PM
(#18455262)
Except you've missed 2x7-2x9...
Re:Pattern Matching Without Regex – Introducing the Rosie Pa...
by samatman on Friday November 16, 2018 @03:21AM
(#18467359)
Ah, you're right, that was careless of me
here's the real deal courtesy of the URI spec:
IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
dec-octet = DIGIT ; 0-9
/ %x31-39 DIGIT ; 10-99
/ "1" 2DIGIT ; 100-199
/ "2" %x30-34 DIGIT ; 200-249
/ "25" %x30-35 ; 250-255
Re:Pattern Matching Without Regex – Introducing the Rosie Pa...
by setr on Wednesday November 14, 2018 @02:50PM
(#18453211)
It seems to me that validating on the AST would be a lot cleaner/saner (if int(ipv4addr) > 256: err), and generally allow for much better error messages; especially since you'll be doing almost all your validations on the AST anyways.
It would ofc also be more useful in future parsing too (similar structure, but not ipv4), but thats a much more minor and rarer benefit