fork(1) download
  1. <?php
  2.  
  3. // your code goes here
  4. $regex = '/\bM\b(\s*[<>=]\s*\d+|\s+between\s+\d+\s+and\s+\d+)/';
  5. $str = '(a > 3) and ( b + c = 4 and M < 4) and (d + e = 6 and M between 4 and 6) and z>10';
  6. if (preg_match_all($regex, $str, $matches)) {
  7. foreach ($matches[0] as $m) {
  8. echo $m. PHP_EOL;
  9. }
  10. }
Success #stdin #stdout 0.02s 24468KB
stdin
Standard input is empty
stdout
M < 4
M between 4 and 6