$text = "this is TWOblaredbla bla"; $text =~ s#<(.+?\s(.+?)=.+?)>(.+?)<\/.+?>#<$1>$3<\/$2>#g; print "$text\n";