print splitter($string,"<.*?>",'(\S{18})','$1 '); sub splitter{ my($string,$spliton,$find,$replace)=@_; my @array=split(/$spliton/,$string); my $i=0; my @splitters; my $str; while($string=~/($spliton)/g){ push @splitters,$1; } my $a; for (@array){ eval "s/$find/$replace/g; "; die "$@" if $@; $str.=$array[$i]; $str.=$splitters[$i]; $i++; } $str; }