Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

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

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 - 11 hours ago