http://www.perlmonks.org?node_id=573705


in reply to Re^3: Regex problem while parsing tagged, hierarchical data
in thread Regex problem while parsing tagged, hierarchical data

Ups !! -1 char
perl -pi -e '/(<level(1|2))(\sid=\".*\")*>/;$&?$2==1?$b=$3:$_=~s;($1); +$1$b;g:1' input


Mago
mago@rio.pm.org