Last active
August 29, 2015 13:57
-
-
Save mboynes/9378908 to your computer and use it in GitHub Desktop.
Get html attributes from a given html tag
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
function get_html_attributes(s) { | |
var reg = /\s+([^\t\n\r\f \/>"'=]+)(?:\s*=\s*(['"])(.*?)\2)?/,attr = {}; | |
while ((result = reg.exec(s)) !== null) { | |
attr[result[1]] = result[3]; | |
s = s.replace(reg,''); | |
} | |
return attr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment