Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-12-20 19:40
Updated·2026-01-06 22:24
Flavor·JavaScript

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

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