undef $/; $str =; while ($str =~ /<([^\/]*[^>]*)>((?:(?!<\/\1>).)*)<\/\1>/gsi) { print "Data inside $1 tag:\t$2\n"; }