Last active
September 13, 2016 08:18
-
-
Save pcrov/a6337227c56ca5719fd7 to your computer and use it in GitHub Desktop.
XMLDecl from http://www.w3.org/TR/xml/#xmldoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// XMLDecl from http://www.w3.org/TR/xml/#xmldoc | |
$regex = <<<'REGEX' | |
/ | |
(?(DEFINE) | |
(?<S> [\x20\x9\xD\xA]+ ) | |
(?<Eq> (?&S)? = (?&S)? ) | |
) | |
^(?<XMLDecl> | |
<\?xml | |
(?<VersionInfo> | |
(?&S) version (?&Eq) | |
(?| | |
'(?<VersionNum> 1\.[0-9]+ )' | | |
"(?<VersionNum> 1\.[0-9]+ )" | |
) | |
) | |
(?<EncodingDecl> | |
(?&S) encoding (?&Eq) | |
(?| | |
'(?<EncName> [A-Za-z] (?:[A-Za-z0-9._] | -)*)' | | |
"(?<EncName> [A-Za-z] (?:[A-Za-z0-9._] | -)*)" | |
) | |
)? | |
(?<SDDecl> | |
(?&S) standalone (?&Eq) | |
(?| | |
'(?<Standalone> yes | no)' | | |
"(?<Standalone> yes | no)" | |
) | |
)? | |
(?&S)? \?> | |
) | |
/x | |
REGEX; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment