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
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Matching an IP address
by Fastolfe (Vicar) on Aug 02, 2000 at 00:57 UTC | |
by young perlhopper (Scribe) on Aug 02, 2000 at 01:00 UTC | |
by Fastolfe (Vicar) on Aug 02, 2000 at 01:15 UTC |
In Section
Snippets Section