in reply to Matching an IP address
Are you sure you want to allow 0 as the first character?
Or three 0's as the first octet? IP addresses don't really
lend themselves to regular expressions. If you really want
to check for correctness i'd do something like this:
Okay, okay, it ain't briefer, but it will probably enforce something more like an actual IP address.foreach $octet (split /\./, $ipaddr) { # # check each octet here (numerically, not with # a regex!), i've gotta jet # or i'd write it myself # }
Then again, if you are just trying to pick out IP addresses in text, you might be alright with your regex... You won't find strings like '304.00.3.999' very often in text files.
Hope this helps,
Mark
In Section
Snippets Section