Webflags: g
HTML Attribute
Match HTML attributes of the form name="value" or name='value' and capture both parts.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b([a-zA-Z][a-zA-Z0-9\-]*)=["']([^"']*)["'] (flags: g)Raw source: \b([a-zA-Z][a-zA-Z0-9\-]*)=["']([^"']*)["']
How it works
Group 1 captures the attribute name (letters, digits, hyphen). Group 2 captures the quoted value. Matches both double and single quoted forms.
Examples
Input
<a href="https://x.com">Matches
href="https://x.com"
Input
<img alt='logo' src='/a.png'>Matches
alt='logo'src='/a.png'
Input
<div></div>No match
—Common use cases
- •HTML template parsing
- •Attribute extraction for SEO audits
- •Accessibility linting (alt, aria-*)
- •Static analysis of template files
Related patterns
HTML Tag Matcher
WebMatch paired HTML tags and capture the tag name and inner content using a back-reference.
CSS Class from `class=""` Attribute
WebExtract the value of a `class="..."` attribute from raw HTML, handling double or single quotes.
HTML Entity
WebMatch HTML entities in named (`&`), numeric (`{`), or hex (`💩`) form.
Cookie Header Value
WebParse name=value pairs from an HTTP `Cookie:` header value.