in reply to Regular Expression Doubt

$text =~ s {( # Capture in $1 <maths> # Tag [^<]* # Not a <, zero or more times (?: # Group, non-capture. < # <, (?!/maths>) # not followed by /maths> [^<]* # Not a <, zero or more times )* # Repeat. </maths> # End tag. ) # End capture $1. | # Or &plus; # Target. } {$1 || "&thinsp;&plus;&thinsp;"}exg;