[H-GEN] regular expressions

Michael Anthon michael at anthon.net
Fri Aug 18 23:49:08 EDT 2000


[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

> > If you want to handle tabs and such as well, try this...
> > sed "s/[[:space:]]\+/|/g"
> 
> I always trap my sed expressions in forward-quotes to hide them
> completely from the shell.  [ObPeeve:  forward quotes cannot be
> escaped from bash _at all_.]
> 
I'm reading between the lines here a bit, so if I am misinterpreting,
then I apologise.... the \ before the + is NOT there for any shell
expansion reasons.  The double quote are there to prevent the shell from
changing \+ to just +, here's an extract from the 'ed' man pages...

       \+      Matches the single character regular expression or
               subexpression immediately preceding it one or more
               times.   So  the regular expression `a+' is short­
               hand for `aa*'.  If \+ occurs at the beginning  of
               a  regular  expression  or  subexpression, then it
               matches a literal `+'.

Cheers
Michael Anthon

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list