[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[grep 2.5.1] odd output for some patterns combining backreference, alter
From: |
Alex Lamey |
Subject: |
[grep 2.5.1] odd output for some patterns combining backreference, alternation, and repetition |
Date: |
Sun, 30 Sep 2007 16:03:40 -0400 |
Hi,
I think grep (2.5.1) is misbehaving on me. Here are twelve examples,
wherein I apply six patterns (differing only in the repetition
argument) to two inputs (differing only in their fifth character).
Five of the outputs (marked '!') seem to be wrong to me. But I'm
quite new to grep so maybe I've misunderstood something.
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){1}'
88-8
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){2}'
88-88
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){3}'
88-88
!
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){4}'
88-8
!!
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){5}'
88-88
!
$ echo 88-88 | egrep -o '([0-9])([0-9])-(\1|\2){6}'
88-88
!
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){1}'
88-8
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){2}'
88-8
!
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){3}'
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){4}'
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){5}'
$ echo 88-81 | egrep -o '([0-9])([0-9])-(\1|\2){6}'
If this isn't a bug, but a mistake on my part, an explanation would
be appreciated.
Thanks,
-Alex
- [grep 2.5.1] odd output for some patterns combining backreference, alternation, and repetition,
Alex Lamey <=