Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: dir match, dir may or may not appear

by hellosarathy (Novice)
on Jan 12, 2016 at 09:13 UTC ( [id://1152539]=note: print w/replies, xml ) Need Help??


in reply to Re: dir match, dir may or may not appear
in thread dir match, dir may or may not appear

the regexp has errors:
Nested quantifiers in regex marked by <-- HERE in m/^/usr/(/[^/]+{ <- +- HERE 0,1})/bin//
Two expressions is fine,is there a one liner, as this could increase in future...?

Replies are listed 'Best First'.
Re^3: dir match, dir may or may not appear
by Corion (Patriarch) on Jan 12, 2016 at 09:18 UTC

    Yes, see perlre. If one expression is too difficult, why not use two?

    If you really need to write it in one expression, use a group and quantify that:

    m!^/usr(?:/[^/]+)?/bin!;
Re^3: dir match, dir may or may not appear
by Anonymous Monk on Jan 12, 2016 at 09:20 UTC

    a quantifier is +

    a quantifier is {0,1}

    You can't have {0,1}{0,1}{0,1}{0,1}

    You can't have +{0,1}+{0,1}

    If you want a pattern ([^/]+) to repeat, you have to group it

    perlre, perlretut, perlrequick describe these words I've used, go fish

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-29 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found