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