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 |
In Section
Seekers of Perl Wisdom