Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regex help

by GrandFather (Sage)
on Sep 10, 2012 at 04:00 UTC ( #992660=note: print w/replies, xml ) Need Help??


in reply to Regex help

+ is greedy and will match as many of whatever it applies to as it can. Generally it is smart to avoid . and use an explicit set of characters to match. In this case everything except / looks like it may be what you want:

$str =~ m!(.+)(/path/)([^/]+)(/.+)!

Note that I used ! as the regex delimiter to avoid having to quote all the / characters.

True laziness is hard work

Replies are listed 'Best First'.
Re^2: Regex help
by yoda54 (Monk) on Sep 10, 2012 at 04:06 UTC
    Thank you sir! :-D

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992660]
help
Chatterbox?
[Eily]: that's the internet for you LanX
[Eily]: and I'm pretty sure there's a rule somewhere that states that the stupider the idea, the more likely it is to already have been done
zentara is thinking of moving to Mars to esacpe it all
[LanX]: Zentara eq Dr Manhatten ?
[zentara]: more like Dr. Helion3 :-)
[LanX]: Eily: though I haven't found a a reference for this one yet : Re^2: OT: Got fired this week (orange)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2017-03-27 15:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.