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.
In reply to Re^2: regex greedy range
by ikegami
in thread regex greedy range
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |