http://qs1969.pair.com?node_id=144759


in reply to regexp question

Try this pattern:

/^$path(?=(\/[\S\/]*|$))/

It says, more or less: match the contents of $path, but only if followed by a slash (and optionally more slashes and non-space characters), or the end of the line. Here's my test program

#!/usr/bin/perl -w my $path='/tmp/foo'; my @ex=('/tmp/foo', '/tmp/foo/', '/tmp/foo/bar', '/baz/tmp/foo/', '/tm +p/food'); print join(" ", grep( /^$path(?=(\/[\w\/]*|$))/, @ex)), "\n";