Error in preg_replace, PHP

0

I am using this line of code:

$routerPattern = "#^" . preg_replace('/\\:[a-zA-Z0-9\_\-]+/', '([a-zA-Z0-9\-\_]+)', preg_quote($route)). "$#D";

In my PHP code for a program, this function must use regular expressions to find this character ':' .

The rich text editor (Visual Studio Code) gives me a syntactic error in the quotation marks that surround regular expressions, and I do not understand why, since it is apparently written in the correct way.

The error is real and do not concern the text editor, because when you insert this line, the PHP code stops working.

I think it's because of '/ since the character may be escaping.

The fact is that I do not know how to solve it. Could someone tell me what I'm failing? Thanks.

    
asked by Sergio Gutiérrez 26.09.2018 в 20:50
source

0 answers