Link to home
Start Free TrialLog in
Avatar of jrram
jrramFlag for United States of America

asked on

Does SED support alternation regular expression?

Hello,

Here is an example of my data:

<frame context=".*/batch">
</frame>
<frame context=".*/continuous">
</frame>

================================

I am trying convert the above data to look like:
<frame>
</frame>
<frame>
</frame>

================================

I currently have these two sed scripts that do the job, but I am trying to combine into one statement:

     sed -i "/<frame /,/>/ s/ context=\"\.\*\/batch\"//g" $PRODUCTDIR/kb/framesPTP.xml
     sed -i "/<frame /,/>/ s/ context=\"\.\*\/continuous\"//g" $PRODUCTDIR/kb/framesPTP.xml


I tried:

     sed -i "/<frame /,/>/ s/ context=\"\.\*\/(batch|continuous)\"//g" $PRODUCTDIR/kb/framesPTP.xml

But it does not work for me.  When I use the pipe to get the either/or it doesn't do any substitution at all.  Help please.


ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jrram

ASKER

I'm using GNU sed version 4.1.2
I am unable to test that here but I don't see the issue with the alternation.
Thanks for the question and the points.