in reply to Re: regex greedy range
in thread regex greedy range
You forgot a bunch of question marks, and you're using capturing when you only need grouping:
m!((((\w+/)\w+/)\w+/)\w+/?)!;
should be:
m!((?:(?:(?:\w+/)?\w+/)?\w+/)?\w+/?)!;
but that requires lots of backtracking, so I think it's less efficient than:
m!(\w+(?:/\w+(?:/\w+(?:/\w+)?)?)?)!;
which only requires a single character lookahead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex greedy range
by Aristotle (Chancellor) on Sep 16, 2004 at 23:47 UTC |