[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: plus sign appears not to work as expected
From: |
arnold |
Subject: |
Re: plus sign appears not to work as expected |
Date: |
Sat, 11 Feb 2012 23:40:46 -0800 |
Hi Bill.
The issues are your unerstanding of regular expressions.
> I had hoped to find a help list because this may be my problem, but here
> goes:
>
> grep --color '^[[:alpha:]]*' xxx
> Lists every line including blank lines, highlighting leading alpha strings.
Correct. The * means zero or more alphabetic characters, and ^ means beginning
of line. The ^ always matches every line, even though the [[:alpha:]]* may
not.
> grep --color '^[[:alpha:]][[:alpha:]]*' xxx
> Lists every line starting with an alpha and highlights all leading alphas.
> This is what I wanted, so I tried rewriting the spec as:
>
> grep --color '^[[:alpha:]]+' xxx
> lists nothing.
For grep, you need '^[[:alpha:]]\+'.
HTH,
Arnold
Re: plus sign appears not to work as expected, arnold, 2012/02/12