in reply to Re^4: Regular Expression Doubt
in thread Regular Expression Doubt

Eh, if you go that way, it could be made much more efficient. No need for the s/// - you're matching any + already:
my $output = ""; while ($text =~ m{\G(?:&plus;|(<maths>.*?<\/maths>|[^&<]+|.))}gs) { $output .= $1 || "&thinsp;&plus;&thinsp;"; } print $output, "\n";