note 85697 added to function.preg-match
| From: | Ashus at osu1 dot php dot net | Date: | Fri, 12 Sep 2008 15:18:33 +0000 |
| Subject: | note 85697 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144369@lists.php.net to get a copy of this message | ||
If you need to match specific wildcards in IP address, you can use this regexp:
<?php
$ip = '10.1.66.22';
$cmp = '10.1.??.*';
$cnt = preg_match('/^'
.str_replace(
array('\*','\?'),
array('(.*?)','[0-9]'),
preg_quote($cmp)).'$/',
$ip);
echo $cnt;
?>
where '?' is exactly one digit and '*' is any number of any characters. $cmp
mask can be provided wild by user, $cnt equals (int) 1 on match or 0.
----
Server IP: 147.32.160.17
Probable Submitter: 85.135.75.196
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/85697
Del: integrated -- https://master.php.net/note/delete/85697/integrated
Del: useless -- https://master.php.net/note/delete/85697/useless
Del: bad code -- https://master.php.net/note/delete/85697/bad+code
Del: spam -- https://master.php.net/note/delete/85697/spam
Del: non-english -- https://master.php.net/note/delete/85697/non-english
Del: in docs -- https://master.php.net/note/delete/85697/in+docs
Del: other reasons-- https://master.php.net/note/delete/85697
Reject -- https://master.php.net/note/reject/85697
Search -- https://master.php.net/manage/user-notes.php