note 85697 deleted from function.preg-match by cmb

From: Date: Sun, 28 Oct 2018 10:45:56 +0000
Subject: note 85697 deleted from function.preg-match by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209541@lists.php.net to get a copy of this message
Note Submitter: Ashus ---- 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.

« previous php.notes (#209541) next »