mountainbiker
Programmer
Say we have a pattern we want to match. This pattern is used many times in the program. For this example, lets say this is what we have:
/\d{8}.*\.html/;
Now lets make the pattern a variable, so the following would work:
$pattern = "\\d{8}.*\\.html";
/$pattern/;
Problem:
How can we avoid having to escape the '\' or other metachars in $pattern?
/\d{8}.*\.html/;
Now lets make the pattern a variable, so the following would work:
$pattern = "\\d{8}.*\\.html";
/$pattern/;
Problem:
How can we avoid having to escape the '\' or other metachars in $pattern?