fork download
  1. <?php
  2.  
  3.  
  4. 'FLOAT',
  5.  
  6. ';\s*?q=
  7. (1|0 # 1 or 0
  8. (\. # Literal dot
  9. ([0-9]{1,2}[1-9]| # One or Two Zeroes followed by 1...9 -OR-
  10. [0-9][1-9][0-9]?| # Zero followed by 1...9, followed by an optional 0...9 -OR-
  11. [1-9] # 1...9 followed by:
  12. ([0-9]{0,2}| # None and up to Two 0...9 -OR-
  13. [0-9][1-9]| # 0...9 and then followed by 1...9 -OR-
  14. [1-9]{1,3} # 1...9 once and up to three
  15. )
  16. )
  17. )? # All this is optional, and refers to float range
  18. )'
  19. );
  20.  
  21. preg_match( sprintf( '@(?<params>%s)@x', FLOAT ), ';q=0.3444', $matches );
  22.  
  23. var_dump( $matches );
Success #stdin #stdout 0s 13112KB
stdin
Standard input is empty
stdout
array(6) {
  [0]=>
  string(8) ";q=0.344"
  ["params"]=>
  string(8) ";q=0.344"
  [1]=>
  string(8) ";q=0.344"
  [2]=>
  string(5) "0.344"
  [3]=>
  string(4) ".344"
  [4]=>
  string(3) "344"
}