I think this will do it:
preg_match('/\d{1,3}(?:,\d{3}+)*(?= rx)/i', $data, $match);
?=
is a positive lookahead -- it requires the previous regexp to be followed by this group. And i
makes the regexp case-insensitive, so it will match RX
, rx
, or any combination.