[H-GEN] regular expressions

Jason Henry Parker jasonp at uq.net.au
Fri Aug 18 19:10:36 EDT 2000


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

Michael Anthon <michael at anthon.net> writes:

> 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_.]

> sed does not seem to support the \s as a shrtcut for whitespace.

Not GNU sed, no.  GNU sed treats \s as a literal s.  I'm also pretty
sure the + operator is not understood by GNU sed---which
implementation and version of sed are you using?

As far as I know, \s is a Perl extension (ObReasonToUsePerl:  its
regex syntax is *much* better than average, *and* it's the same on all
systems!).

Martin was definitely on the right track by using tr, however.

jason
-- 
``I worry that you'll work in an office ... have children ... celebrate
wedding anniversaries ... the world of heterosexuals is a sick and
boring life!''  --  Aunt Ida

--
* 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