On Tue, Dec 15, 2009 at 11:57 PM, Luke Kanies <[email protected]> wrote:
> On Dec 14, 2009, at 5:24 PM, Markus Roberts wrote:
>
>>> Any attempt to use regexes to match all cases is somewhat bound for
>>> failure, but this is better than nothing, IMO.
>>
>> Bound to fail?  How so?  I believe the provided regulare expressions
>> match all (and only) valid IP addresses, both IPv4, IPv6, and hybrid
>> (in the commented out version).
>
> I guess I mean in the general sense, rather than in the "I'm actually
> correct" sense.  I also don't know enough about ipv6; I just know my
> attempts at regex-matching IP addresses have been no fun.

Yeah, if you look at them as a grammar, they're a nightmare.  The
trick is to notice that they're enumerable and have a lot of internal
regularity so you can think of the regexp as being all the possible IP
addresses in some natural order separated by pipes (which would work
but be ginormous), and then compressing the heck out of this by
exploiting the regularity.  Keep compressing until the added
cleverness needed to make it smaller hurts readability more than it
helps conciseity.

Oh yeah, and then test the daylights out of it.

-- Markus

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to