protected function _regex($regex, $param, $token, $prefix)
{
if ($regex) {
$this->_subPatterns[$param] = $regex;
} elseif ($param == 'args') {
$regex = '.*';
} else {
$regex = '[^\\/]+';
}
$req = $param === 'args' || array_key_exists($param, $this->_params) ? '?' : '';
if ($prefix === '/') {
$pattern = "(?:/(?P<{$param}>{$regex}){$req}){$req}";
} elseif ($prefix === '.') {
$pattern = "\\.(?P<{$param}>{$regex}){$req}";
} else {
$pattern = "(?P<{$param}>{$regex}){$req}";
}
return str_replace($token, $pattern, $this->_pattern);
}