in reply to Re^3: Regex problem while parsing tagged, hierarchical datain thread Regex problem while parsing tagged, hierarchical data
perl -pi -e '/(<level(1|2))(\sid=\".*\")*>/;$&?$2==1?$b=$3:$_=~s;($1);
perl -pi -e '/l1(\sid=.*)>/?$a=$1:s;l2>;l2$a>;' input
Electric eels were invented at the same time as electricity
Before electricity was invented, electric eels had to stun with gas
Results (322 votes). Check out past polls.