HTML Attribute
intermediateExtracts attribute name-value pairs from HTML tags.
htmlattributeparsingweb
Pattern
/([a-zA-Z-]+)="([^"]*)"|([a-zA-Z-]+)='([^']*)'|([a-zA-Z-]+)=([^\s>]+)/gTry It
0 of 7 strings matched
Explanation
Matches HTML attributes in three formats: double-quoted (attr="value"), single-quoted (attr='value'), or unquoted (attr=value).
Test Strings
Matching
- class="container"
- id='main'
- disabled=true
- data-value="test"
Non-matching
- = value
- class
- "value"
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /([a-zA-Z-]+)="([^"]*)"|([a-zA-Z-]+)='([^']*)'|([a-zA-Z-]+)=([^\s>]+)/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);