How to escape the ampersand in regular expressions in php?

The problem with the router
there is a config routes.php
'films([\?][\/&=A-Za-z0-9]+)' => 'films/filters',
'films' => 'films/index',

Processing in the classroom Router.php through
preg_match('~^'.$uriPattern.'$~', $this->uri)

Can't escape the & ampersand in $_GET requests
March 19th 20 at 08:41
1 answer
March 19th 20 at 08:43
If I correctly understood the question
preg_match('~^'.preg_quote($uriPattern, '&').'$~', $this->uri)
not quite right I shall declare.

this regular line does not pass the ampersand, Your code did not help - Geraldine_Abbo commented on March 19th 20 at 08:46
I'm sorry, he was wrong. The router was not working, because there was a sign "_". But the ampersand does not need to be escaped. - Geraldine_Abbo commented on March 19th 20 at 08:49

Find more questions by tags Regular expressionsPHP