If I have want to combine tags with compatible attributes like... <font color="blue" font="Times"><font size="14"abcdegh</font></font> to <font color="blue" font="Times" size="14"abcdegh</font> as I have have it all in one scalar variable I thoughtI would have something like.. my $startFontTag="<font"; my $endFontTag="</font>"; $string =~ s/$startFontTag[\w*|\s*|\S*]$startFontTag[\w*|\s*|\S*]/$1/gi; but I dont think the above approach is going to work. Should I do something like first check the string to see if any occurence of </font></font> occurse then delete one of them and move back to check staring font tasg and to combine them. Thanks!