Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created March 16, 2014 16:18
Show Gist options
  • Save robozevel/9585681 to your computer and use it in GitHub Desktop.
Save robozevel/9585681 to your computer and use it in GitHub Desktop.
Detect HTML strings (extracted from jQuery's core)
// https://github.com/jquery/jquery/blob/master/src/core/init.js#L14
var isHTMLString = (function() {
var rHTML = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/;
return function(str) {
return rHTML.test(str);
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment