use strict; my $str = q{sometext with conetnst add kklkk&dfaf:dfaÜÄmlddö;}; $str =~ s/&([^;]+);/&$1 ;/g; #This includes all the characters till the semicolon print $str;