Ack with regex - Confusion with simple queries

Viewed 13154

I am trying to use ack-is-better-than-grep (ack) with regular expressions to find lines and snippets in my code repository. My understanding is that ack uses Perl-derivative regular expressions, is that correct?

However, I am not sure how would these queries work:

ack 'foo'
ack '.*(foo)+.*'

ack '.*foo'
ack 'foo.*'

Could they give different outputs? If so, why?

EDIT: In my tests they output different results (the first one outputs more matches than the others, for example). They also highlight different parts of the same lines.

EDIT 2: The difference in the output apparently is related to the highlighting (the coloring of the output). I have noticed that if I run ack with --nocolor the output of the commands above are the same. Apparently running ack with the default coloring makes part of the output invisible in my machine/config. I am running it on a GNOME terminal from bash in Ubuntu 11.04.

1 Answers
Related