fork download
  1. <?php
  2.  
  3. $testdata = array('1~ 2,906,730 RX',
  4. '1-.’ 2,733,975 Rx',
  5. '/ 132,882 RX mu uuu Au',
  6. '\'2(*__/ 182 rX ....212');
  7. foreach ($testdata as $data) {
  8. if (preg_match('/\d{1,3}(?:,\d{3}+)*(?= rx)/i', $data, $match)) {
  9. echo $match[0], "\n";
  10. }
  11. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
2,906,730
2,733,975
132,882
182