Created
September 7, 2016 14:18
-
-
Save jserrao/833fb0dfc90089db299b15c9e62b454b to your computer and use it in GitHub Desktop.
Basic regex for HTML
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
// All regex start and with forward slashes | |
/(conditions-here)/ | |
// Put g character at end of regex to get recursion | |
/(conditions-here)/g | |
// Matches all opening HTML tags | |
/(<\w+\b>)/g | |
// Matches all <a href="anything"> | |
/(<a\shref=".*">)/g | |
// Matches any word | |
/(\w+\b)/g | |
// Matches any closing HTML tag </a></li></ul> | |
/(<\/\w+\b)>)/g | |
// Matches all opening and closing tags without attributes | |
/(<)((\w+\b)|(\/\w+\b)|)(>)/g | |
// Regex that combs through opening and closing HTML tags, <a href="whatever.html" | |
/((<\w+\b>)|(<a\shref=".*">)|(\w+\b)|(<\/\w+\b)>)/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment