note 107178 modified in function.preg-quote by danbrown

From: Date: Thu, 12 Jan 2012 17:55:23 +0000
Subject: note 107178 modified in function.preg-quote by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185616@lists.php.net to get a copy of this message
If you need to quote everything but a wildcard, maybe this function will come handy to you: <?php protected function _ruleOptionIsMatched($option, $subject) { $option = preg_quote($option, '#'); $option = str_replace('\*', '.*', $option); if(preg_match("#^$option$#", $subject)) { return true; } else { return false; } } ?> --was-- If you need to quote everything but a wildcard, maybe this function will come handy to you: protected function _ruleOptionIsMatched($option, $subject) { $option = preg_quote($option, '#'); $option = str_replace('\*', '.*', $option); if(preg_match("#^$option$#", $subject)) { return true; } else { return false; } } http://php.net/manual/en/function.preg-quote.php

« previous php.notes (#185616) next »