Non greedy pattern match in sed

Matthew Hawkins matt at
Wed Aug 14 16:55:04 EST 2002

Just nitpicking ;)

Kim Holburn (kim.holburn at wrote:
> "*" means multiple instances of (whatever came first in this case ".")

Actually "+" means multiple (1 or more) matches of the preceeding atom.
"*" means 0 or more. [1]  Subtle but important difference.

Just to confuse things, in POSIX extended regular expressions, "?" means
0 or 1 matches (equivalent to {0,1}) of the preceeding atom, but is used
to specify a non-greedy match in Perl RE's.

You could go really nuts and try an expression like so:


[1] Assuming POSIX 1003.2 extended RE's

"So, logically, if she weighs the same as a duck, she's made of wood, and therefore a witch!"
(Monty Python and the Holy Grail)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the linux mailing list