Thus said Jeff Anderson on Tue, 21 Jan 2014 21:37:24 -0700:

> It  looks like a  lone ^ by  itself in a  character class is  a syntax
> error:

Not if  you escape  it (which must  necessarily be so  because ^  at the
beginning of a bracket expression means *not*:

$ echo 'here^H' | grep '[\^]'
here^H

But  this  is  not true  if  the  ^  is  anywhere else  in  the  bracket
expression:

$ echo 'here^H' | grep '[a^]' 
here^H

The same is true if you just have an  RE of a single ^ (or if you want a
^ at the beginning of an expression):

$ echo 'no carat for me please' | grep '^'
no carat for me please

Notice  that it  matched, because  ^ at  the begining  of an  expression
anchors it to the beginning of the  line, which will always match if you
have lines.

$ echo 'no carat for me please' | grep '\^'
$ echo $?
1

Andy
-- 
TAI64 timestamp: 4000000052df5035



/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to