Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-02-22 19:45
Flavor·Java

"
(?<type>text|font|model|audio|image|video|application|message|multipart) \/ ( (?<tree>[-_0-9a-z\.]+\.)? (?<subtree>[-_0-9a-z]+)* ) (\+ (?<suffix>[-_a-z0-9]+) )? (?<parameters>;\s* (?<parameter>(?<param>[-a-z0-9]+)\s*=\s*(?<value>[-a-z0-9]+)) )*
"
ixg
Open regex in editor

Description

Parses an IANA Media Type value.

Doesn't seem to capture repeating parameters, which is a bit of an edge case but valid I think - any suggestions on how to fix would be appreciated.

Submitted by scottbdr