Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: regexp question

by hawson (Monk)
on Feb 12, 2002 at 02:04 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (None)
    As of 2024-04-25 01:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found