Subject: Re: awk problem with `{n[,[m]]}' repetition operator
To: None <netbsd-users@netbsd.org>
From: None <tlaronde@polynum.com>
List: netbsd-users
Date: 08/08/2005 20:16:00
On Mon, Aug 08, 2005 at 05:31:20PM +0200, Jukka Salmi wrote:
> Hi,
> 
> on both -current (awk version 20050424) and 2.0_STABLE (awk version
> 20030729) I see the following:
> 
> 	$ echo '123' | awk '/^[0-9]{3}$/{print;}'
> 	$ echo '123' | awk '/^[0-9]{1,}$/{print;}'
> 	$ echo '123' | awk '/^[0-9]{1,3}$/{print;}'
> 
> I expect `123' to be printed. BTW, `*' and `+' work fine:
> 
> 	$ echo '123' | awk '/^[0-9]+$/{print;}'
> 	123
> 	$ echo '123' | awk '/^[0-9]*$/{print;}'
> 	123
> 
> Is this a bug, or am I missing something?

FWIW, after a cursory look at the grammar in the sources the range
doesn't seem to be handled.
And in "Sed & Awk" by Dougherty & Robbins (O'Reilly) [this is not meant
to be _the_ reference, it is merely information], a note says that
the {n,m} range is in POSIX egrep and awk but "most awk implementations
do not yet support this notation". (well, it's the 2nd edition dated
1997, but it seems still true).

Cheers,
-- 
Thierry Laronde (Alceste) <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.org/  |  http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C