Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Regular Expression to Match IP Address

by Ven'Tatsu (Deacon)
on Oct 04, 2004 at 15:51 UTC ( [id://396266]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Regular Expression to Match IP Address
in thread Regular Expression to Match IP Address

I fail to see why you make the distinction about strings. The OP is reading input on STDIN, all input will be strings, the point of the post your replying to is that there are more ways to represent an IP address in a string than just dotted decimal quads. Many IP aware applications can accept IP addresses in decimal, hex, or octal in either a single 32 bit number, or 4 dot separated 8 bit numbers (aka dotted quad)

My web browser seems perfectly happy when I pass it a string with an unsigned 32 bit integer and just as happy to get a dotted hex quad.

The OP may not care to accept any thing but decimal dotted quads, but the classic (and almost trite) saying is "Be liberal in what you accept and strict in what you emit." To not mention that there are alternate encodings that he may encounter could cause him trouble in the future.

  • Comment on Re^5: Regular Expression to Match IP Address

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://396266]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found