Possible bug with '*' pattern matching

3 views
Skip to first unread message

Ori Avtalion

unread,
Aug 26, 2008, 12:40:44 PM8/26/08
to ack-...@googlegroups.com
Hi,

I think I found a bug, but perhaps I'm misunderstanding pattern
matching. I'm using the latest svn r910.

Given the following file:

$ cat test
123 foo bar
abcd
efgh
234 bar baz
ijk
############ EOF

I have done two searches:

### this colors the first digit in each line
$ ack '^[[:digit:]]' test
123 foo bar
234 bar baz
############ end of output


### this colors '123' and '234' on the two lines,
### and prints the entire file. '-C 0' has no effect
$ ack '^[[:digit:]]*' test
123 foo bar
abcd
efgh
234 bar baz
ijk
############ end of output

Is something wrong with my ack calls?

Thanks,
Ori

Andy Lester

unread,
Aug 26, 2008, 12:50:08 PM8/26/08
to ack-...@googlegroups.com

On Aug 26, 2008, at 11:40 AM, Ori Avtalion wrote:

> ### this colors '123' and '234' on the two lines,
> ### and prints the entire file. '-C 0' has no effect
> $ ack '^[[:digit:]]*' test
> 123 foo bar
> abcd
> efgh
> 234 bar baz
> ijk
> ############ end of output


You're misunderstanding *. * means "0 or more". Every line in the
file matches zero or more digits.

You want +, which is "one or more".

xoxo,
Andy

--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance


Reply all
Reply to author
Forward
0 new messages