Skip to content

Instantly share code, notes, and snippets.

@alanhogan
Created August 31, 2011 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanhogan/1184841 to your computer and use it in GitHub Desktop.
Save alanhogan/1184841 to your computer and use it in GitHub Desktop.
Meta Charset Heuristic
/ \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