Webflags: gi
HTTP Content-Type Header
Parse the value of an HTTP Content-Type header, capturing the media type and optional charset.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
Content-Type:\s*([a-z]+\/[\w.+\-]+)(?:;\s*charset=([\w\-]+))? (flags: gi)Raw source: Content-Type:\s*([a-z]+\/[\w.+\-]+)(?:;\s*charset=([\w\-]+))?
How it works
Content-Type:\s* matches the header name and required whitespace. ([a-z]+\/[\w.+\-]+) captures the type/subtype (the i flag makes this case-insensitive). (?:;\s*charset=([\w\-]+))? optionally captures a charset parameter — UTF-8, iso-8859-1, etc.
Examples
Input
Content-Type: text/html; charset=utf-8Matches
Content-Type: text/html; charset=utf-8
Input
content-type: application/jsonMatches
content-type: application/json
Input
Authorization: Basic xyzNo match
—Common use cases
- •Reverse-proxy / WAF rule matching
- •API gateway request inspection
- •HTTP log analysis
- •Content-negotiation debugging
Related patterns
Cookie Header Value
WebParse name=value pairs from an HTTP `Cookie:` header value.
CSS hsl() / hsla() Color
WebMatch CSS hsl() and hsla() color functions, capturing hue (0–360), saturation, lightness, and optional alpha.
HTML Attribute
WebMatch HTML attributes of the form name="value" or name='value' and capture both parts.
HTML5 Color Input Value
WebValidate the value of an HTML5 `<input type="color">` — exactly 6 hex digits with leading hash.