On Sun, Feb 17, 2008 at 12:14:51PM -0600, delta wrote:
> Package: grep
> Version: 2.5.3~dfsg-3
> Severity: normal
>
> I was testing the repetition on grep
> all working except {,m}
>
> In the manual appear
> {,m} The preceding item is matched at most m times.
> but i used in didn't work
>
> Here's a little test
> echo 1 11 111 1111 | grep '[0-9]\{,2\}'
> grep: contador de repetición erróneo
Good point. In perl, {,n} isn't valid (perlre(1): "the lower bound is
not optional"), but I don't know if that's relevant to grep.
I note that your regex might not work as intended, since [0-9]{0}
doesn't *avoid* lines matching [0-9] (like grep -v would), but will
match even '1111' (due to ability of the right-most 0-length string to
match [0-9]{0}).
I also note the difference between these two:
grep -e '[0-9]\{,2\}'
That gives an error due to the missing lower-bound; this could be either
a bug in the documentation or in the grep source.
grep -Ee '[0-9]{,2}'
That searches for a digit followed by the string "{,2}", not a repeat
count, due to the missing lower bound.