anyone can help me with this problem.
example $uri = '/username/carlos'; => $routes[] = '/username/@name';
@name convert in variable $name capturing string "carlos"
$routes[] = '/list/edit/@id:[0-9]{3}';
$routes[] = '/username/@name';
$routes[] = '/archive/*';
$routes[] = '/';
$uri = '/username/carlos';
foreach ( $routes as $pattern )
{
if ( preg_match( '#^' . preg_replace( '#(?:{{)?@(\w+\b)(?:}})?#i', '(?P<\1>[\w\-\.!~\*\'"(),\s]+)',
str_replace( '\*', '(.*)', preg_quote( $pattern, '/' ) ) ) . '\/?$#i', $uri, $matchs ) )
{
//how to make regex for this to work :
echo $name; // carlos =>$uri = '/username/carlos'; or matt => $uri = '/username/matt';
}
}
thanks for reading