Webflags: g
XML Namespace Declaration
Match XML namespace declarations (`xmlns="..."` and `xmlns:prefix="..."`), capturing the prefix and URI.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
xmlns(?::([\w\-]+))?\s*=\s*["']([^"']+)["'] (flags: g)Raw source: xmlns(?::([\w\-]+))?\s*=\s*["']([^"']+)["']
How it works
xmlns matches the literal attribute name. (?::([\w\-]+))? optionally captures a colon-prefix (e.g. `xmlns:xlink`). \s*=\s* matches the equals with optional whitespace. ["']([^"']+)["'] captures the URI in either quote style.
Examples
Input
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">Matches
xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"
Input
<root xmlns='urn:custom'>Matches
xmlns='urn:custom'
Input
<plain>No match
—Common use cases
- •XML schema migration tooling
- •SVG / SOAP message parsing
- •Namespace conflict detection
- •XML-to-JSON conversion preprocessors
Related patterns
XML Processing Instruction
WebMatch XML processing instructions like `<?xml version="1.0" encoding="utf-8"?>` or `<?xml-stylesheet href="..."?>`.
CSS hsl() / hsla() Color
WebMatch CSS hsl() and hsla() color functions, capturing hue (0–360), saturation, lightness, and optional alpha.
HTTP Content-Type Header
WebParse the value of an HTTP Content-Type header, capturing the media type and optional charset.
Twitter / X URL
WebMatch Twitter/X profile and status URLs, capturing the handle and (optional) tweet ID.