Skip to content

Instantly share code, notes, and snippets.

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 rniswonger/e8773cc532490b0aeb6ff0422c52945d to your computer and use it in GitHub Desktop.
Save rniswonger/e8773cc532490b0aeb6ff0422c52945d to your computer and use it in GitHub Desktop.
RegEx to find html atributes
All attributes:
(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?
A specific attribute (ex. class):
(class)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?
Test it:
https://www.debuggex.com/r/KL_pMoR8_pERK-ah
Credit:
http://stackoverflow.com/questions/317053/regular-expression-for-extracting-tag-attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment