Andriy Sen wrote:
> See tree examples below. The last one shows the problem.
>
>
> G:\>cat test.s
> a
> 1
>
> G:\>od -a test.s
> 0000000 a nl 1 nl
> 0000004
>
> G:\>cat test.s | grep -P "^[^0]1"
>
>
> G:\>cat test.s | grep -P "^(|[^0])1"
> 1
>
> G:\>cat test.s | grep -P "^(|.*[^0])1"
> a
> 1
>
>
what problem?
cat test.s | grep -Pn "^(|.*[^0])1"
# 1:a
# 1
as you can see, there is one match here. '.*' matches 'a', and '[^0]'
matches the newline. and so '1' can match '1'. there is no 'line
before the match'; the line before that containing '1' is *within* the
match.
vQ