note 61986 added to function.preg-match-all

From: Date: Thu, 16 Feb 2006 19:23:32 +0000
Subject: note 61986 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-103856@lists.php.net to get a copy of this message
Correct IP matching Pattern: This is my new IP octet pattern seems to be correct: $num="(25[0-5]|2[0-4]\d|[01]?\d\d|\d)"; /* 25[0-5] => 250-255 2[0-4]\d => 200-249 [01]?\d\d => 00-99,000-199 \d => 0-9 */ GRABBING multiple Valid IP addresses from string <? $num="(25[0-5]|2[0-4]\d|[01]?\d\d|\d)"; $test="127.0.0.112 10.0.0.2"; preg_match_all("/$num\\.$num\\.$num\\.$num/",$test,$match); print_r($match); ?> Single IP validation <? $num="(25[0-5]|2[0-4]\d|[01]?\d\d|\d)"; $ip_addr='009.111.111.100'; if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $ip_addr,$match)) echo "Wrong IP Address\\n"; echo $match[0]; ?> ---- Server IP: 64.246.30.37 Probable Submitter: 85.101.173.95 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61986 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61986&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61986&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103856) next »