$re = '/\w+ \((?:[1-9]|[1234][0-9])\)(?:, )?/m';
$str = 'I can not find a working regular expression to match the strings followed by a number from 1 to 49 in braces, in a list dividing the pairs by comma:
alpha (1), beta (12), gamma (37), delta (49), epsilon (55), zeta (64)
but also in random order and amount of pairs like
zeta (64), alpha (1), gamma (37), beta (12), delta (49), epsilon (55), eta (48), theta (26)
and also random numbers like
zeta (11), gamma (71), beta (49), delta (52), epsilon (99), alpha (33)
I\'m looking for an endresult showing only the pairs with a number lower as 49 like
alpha (1), beta (12), gamma (37), delta (49)
alpha (1), gamma (37), beta (12), delta (49), eta (48), theta (26)
zeta (11), beta (49), alpha (33)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php