Hi,
Can someone help me come up with a generic sed command to clean a tag off its attributes?
For eg.
Input String - <tag attrib=new>This String</tag>
should undergo a sed transformation to get
Output String - <tag >This String</tag>
This works -
echo "<tag attrib=new>This</tag>" | sed -e 's/\([^<\/A-Za-z]\)[^>]*>/\1>/g'
<tag >This</tag>
However, the moment i add a space in there - it goes for a toss
echo "<tag attrib=new>This String</tag>" | sed -e 's/\([^<\/A-Za-z]\)[^>]*>/\1>/g'
<tag >This >
Resolved the above issue using a single replace -
echo "<tag attrib=new>This String</tag>" | sed -e 's/\([^<\/A-Za-z]\)[^>]*>/\1>/'
<tag >This String</tag>
However, it does not handle the scenario -
echo " <tag attrib=new>This String</tag>" | sed -e 's/\([^<\/A-Za-z]\)[^>]*>/\1>/'
>This String</tag>
Any inputs on this will be of great help.