in reply to regex greedy range
Going from
print "$1\n" if m|((?:\w+/){4})|;
to
print "$1\n" if m|((?:\w+/){0,4})|;
gets you halfway there. Add a '?':
print "$1\n" if m|((?:\w+/?){0,4})|;
and there you are.
'{4}' means match exactly 4 times, whereas '{0,4}' means match up to 4 times. The '?' makes the '/' optional.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex greedy range
by Aristotle (Chancellor) on Sep 16, 2004 at 23:55 UTC |