sed not taking [\t]+ tho it takes [\t]*

sed not taking [\t]+ tho it takes [\t]*

Post by tsr.. » Tue, 06 Jun 2000 04:00:00



===================================================
THIS IS OK

% cat test.sh
#!/bin/sh
cat <<EOF | sed 's/^[ \t]*/XXX /'
   abc def
  123 456
 uvw xyz
EOF

% test.sh
XXX abc def
XXX 123 456
XXX uvw xyz

===================================================
BUT CHANGE "[ \t]*" to "[ \t]+" AND IT FAILS - WHY?

% cat test2.sh
#!/bin/sh
cat <<EOF2 | sed 's/^[ \t]+/XXX /'
   abc def
  123 456
 uvw xyz
EOF2

% test2.sh
   abc def
  123 456
 uvw xyz

===================================================
Thanks for any comments,
-Bob
 Andover, MA

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

sed not taking [\t]+ tho it takes [\t]*

Post by Hunter Johns » Tue, 06 Jun 2000 04:00:00



> BUT CHANGE "[ \t]*" to "[ \t]+" AND IT FAILS - WHY?

Because + isn't a special character in sed.  Use [ \t][ \t]* instead.

Hunter
--
J. Hunter Johnson        | "A little consistent wholesome modeling and

(937) 865-6800 x5385     |    true words harshly spoken."
Lexis-Nexis, Dayton, OH  |                               -- Ron Sider

 
 
 

sed not taking [\t]+ tho it takes [\t]*

Post by Jehs » Tue, 06 Jun 2000 04:00:00



> BUT CHANGE "[ \t]*" to "[ \t]+" AND IT FAILS - WHY?

sed does not conform completely to the extended regex rules. Instead
of using "[blah]+", use "[blah]\{1,\}" or "[blah][blah]*".

Moshe

--

nullity.dhs.org, polter.net, resnet.gatech.edu, wreck.org, yo.dhs.org;


 
 
 

sed not taking [\t]+ tho it takes [\t]*

Post by Ken Pizzi » Wed, 07 Jun 2000 04:00:00




>> BUT CHANGE "[ \t]*" to "[ \t]+" AND IT FAILS - WHY?

>sed does not conform completely to the extended regex rules. Instead
>of using "[blah]+", use "[blah]\{1,\}" or "[blah][blah]*".

More precisely: sed does not use "extended" regular expressions,
but simply "basic" regular expressions.  Much closer to grep
than to egrep.

                --Ken Pizzini