Regular Expressions 101

Quality Value, RFC 9110 HTTP Semantics.

Open Workspace
  • JavaScript
  • Match
1

Regular Expression

/
\s*;\s*[qQ]=(?<qvalue>0(?:\.\d{1,3})?|1(?:\.0{1,3})?)
/
gm

Description

To extract the Quality Value (qvalue) according the RFC 9110 HTTP Semantics specifications from the weight of HTTP headers elements, like:

  • Accept-Language
  • Accept
  • Accept-Charset
  • Accept-Encoding
  • TE
  weight = OWS ";" OWS "q=" qvalue
  qvalue = ( "0" [ "." 0*3DIGIT ] )
         / ( "1" [ "." 0*3("0") ] )
Submitted by Daniel D'Leon