in reply to regexp question
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!
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re x 2: regexp question
by Sweeper (Pilgrim) on Feb 12, 2002 at 06:20 UTC |