I was under the impression that a caret symbol means "beginning of the line" with Extended POSIX regular expressions.
However, when I use it with grep it behaves unexpectedly.
#grep --version GNU grep 2.5.4 ...
I am using GNU grep 2.5.4 on Ubuntu 10.04 Lucid Lynx.
I echo out a line ' hello', then pipe it to a grep that searches for "zero-or-more white-space characters followed by the letter h":
#echo ' hello' | grep -E '[:space:]*h' hello
grep finds it ok.
If I add a caret to indicate that I only want the pattern to match "zero-or-more white-space characters followed by the letter h" "at the beginning of the string":
#echo ' hello' | grep -E '^[:space:]*h' #
No matches are found. I would expect the string to have matched because it begins with
white-space followed by
Why does this caret symbol prevent a match?