/** * checks t' see if th' uri matches the regex routes * * @param $uri * @return bool */ public function checkRoute($uri) { foreach ($this->strings as $expression) { // check if it matches the pattern $this->regex->setPattern($expression); if ($this->regex->getMatches($uri)) { $this->matched_uri_parts = explode('/', $uri); return true; } } return false; }
public function testGetMatches() { $regex = new Regex('^\\/(?<controller>[^\\/]+)\\/(?<action>[^\\/]+)\\/(?<varvalpairs>(?:[^\\/]+\\/[^\\/]+\\/?)*)'); $matches = $regex->getMatches('/controller/action/param/value/next-param/next-value') ? true : false; $this->assertTrue($matches); }
private function regexMatch($regex_string) { $regex = new Regex($regex_string); return $regex->getMatches($this->uri); }