There are two methods
Pattern::unquote(), first of which works as
preg_quote() is supposed to
"Welcome\How are you?");Pattern::quote(
Welcome\\How are you\?
...second of which is the direct opposite:
"Welcome\\How are you\?");Pattern::unquote(
Welcome\How are you?
Please, keep in mind that this is not a safe way to create patterns with unsafe characters - for that, consider using Prepared Patterns.
These two methods should be transitive, so:
$output = Pattern::unquote(Pattern::quote($input));
The contract is
$input === $output for any