Untested, but should get the idea across.
my $path =~ /^\Q$str\E # the base string; '\tmp\foo', e.g. (\\.*)? # optionally match a slash, etc. $ # match end of string /x;
Insisting on matching $ at the end of the regex prevents you from matching "extra" chars that don't start with a backslash.
Update: Yes, do escape the base string. (Regex updated.) Thanks Sweeper!
--In reply to Re: regexp question
by FoxtrotUniform
in thread regexp question
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |