P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
\Q or quotemeta is indeed what you needed.
But your problem is not connected with hardcoded regexes vs. regexes in variables. As Samy_rio correctly pointed out, the problem comes from the fact that '.' has a special meaning in a regex which you don't want in your case. Therefore you need to escape it: either by putting a '\' in front of it - which works fine for the hardcoded case an is a bit more complicated for variables OR you use quotemeta resp. \Q which works in both cases. -- Hofmator Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk. In reply to Re^2: Regex Start Anchor with variables
by Hofmator
|
|