in reply to Why does this non-greedy match not work?
Making the .+ non-greedy doesn't change that the dot is perfectly willing to match any / in the inputs (since a dot just matches any (non-newline, by default) character). It's still going to start at the left-most "/" that it sees (the first character) and then start gobbling up one or more things-which-match-dot (which includes all the subsequent letters and "/"s) until it hits the end of the line. If you'd explicitly asked for things-which-are-not-"/" using [^/]+ instead you'd have had more luck (e.g. m{/ ([^/]+) $}x).
Of course this could just be a slight XY problem and you really want File::Basename or Path::Tiny instead . . .
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does this non-greedy match not work? (updated)
by haukex (Archbishop) on Jun 29, 2020 at 19:07 UTC |