I have some problems when trying to make a match with my URL with my regex pattern in PHP.
my regex:
/article/([0-9A-Za-z]++)/post/([0-9A-Za-z-_]++)
public function matches(Route $route){
$uri = filter_var(strip_tags($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL);
if (preg_match('#' . "/article/([0-9A-Za-z]++)/post/([0-9A-Za-z-_]++)" . '#i', $uri, $this->matches)) {
return true;
}
return false;
}
example 1: VALID MATCH (good)
/article/AB545455DSAF54FSA45S4F4/post/FGFG-FGFGF-5FG54FGF-FGFGFG
but also matches this (bad):
/article/AB545455DSAF54FSA45S4F4/post/FGFG-FGFGF-5FG54FGF-FGFGFG/fgfg/fgfgfg/fgf
I want only to match the first example, so how do i fix this? thanks