note 71530 added to function.preg-match-all
| From: | mrcb at osu1 dot php dot net | Date: | Mon, 04 Dec 2006 16:09:26 +0000 |
| Subject: | note 71530 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120271@lists.php.net to get a copy of this message | ||
Regarding parsing of IP addresses:
It seems to be little known that you can, in fact, specify hex and octal values in IP addresses as
well as leaving some octets out (in which case the octet value will be zero). So, for example,
0xab.0177.1 is a valid IP (V4) address and is equivalent to 171.127.0.1. So long as the resultant
combination of hex, octal and decimal is valid within
<0-255>.<0-255>.<0-255>.<0-255> (all decimal values), then, it's an IP
address and not a DNS name. Of course, use this with caution as you may end up trying access a
"network", subnet or broadcast address, if you're not careful - some devices lock up
if PINGing one of these.
You could try to create a single REGEX for parsing this, but you might be best to create a REGEX to
parse each of the (upto) four octets and then test each octet in turn - it depends what you want to
do with the value, store it / process it or simply pass it to the OS via some call (PING, open an
HTTP connection or whatever).
Don't ask me why you'd want to mix hex, octal and decimal in one address.... but it works
on most OSes I know
----
Server IP: 66.163.161.117
Probable Submitter: 194.164.231.237
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/71530
Del: integrated -- https://master.php.net/note/delete/71530/integrated
Del: useless -- https://master.php.net/note/delete/71530/useless
Del: bad code -- https://master.php.net/note/delete/71530/bad+code
Del: spam -- https://master.php.net/note/delete/71530/spam
Del: non-english -- https://master.php.net/note/delete/71530/non-english
Del: in docs -- https://master.php.net/note/delete/71530/in+docs
Del: other reasons-- https://master.php.net/note/delete/71530
Reject -- https://master.php.net/note/reject/71530
Search -- https://master.php.net/manage/user-notes.php