Created
August 31, 2011 21:56
-
-
Save alanhogan/1184841 to your computer and use it in GitHub Desktop.
Meta Charset Heuristic
This file contains 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
/ \b | |
charset= | |
['"]? # optional quotes | |
( # Capture | |
(?: # Non-capturing group, essentially a custom char class | |
\w # word characters | |
| | |
- # or hyphen | |
)+ | |
) | |
['"]? | |
\b | |
] | |
/ix | |
# This should match all charset declarations. | |
# Run on the first 1-2K of the document. | |
# Don't forget to canonicalize the case of the charset! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment