in reply to Regular expression to check XML type

The following are all be equivalent and valid:

And that's assuming you're just supporting UTF-8!

This isn't the job of a regex. But if you insist on using a regex match, here you go:

use XML::LibXML qw( ); local our $doc; $content =~ /(?(?{ !eval { $doc = XML::LibXML->new()->parse_string($_) } })(?!))/;

The match will succeed if the parsing succeeds (and set $doc to a XML::LibXML::Document object) and fail if the parsing fails.