Help for this page
my $output = ""; while ($text =~ m{\G(?:+|(<maths>.*?<\/maths>|[^&<]+|.))}gs) { $output .= $1 || " + "; } print $output, "\n";