Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regexp question

by hawson (Monk)
on Feb 12, 2002 at 02:04 UTC ( #144759=note: print w/replies, xml ) Need Help??


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";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://144759]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2023-01-31 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?