fork download
  1. <?php
  2.  
  3. $format = 'NNTTTNNTTT';
  4. $value = '12AAA22TBI';
  5.  
  6. $format = preg_replace('/[^NT]/', '', $format);
  7. $format = preg_replace('/T/', '[A-Z]', $format);
  8. $format = preg_replace('/N/', '\d', $format);
  9. $format = "/^$format$/";
  10.  
  11. $match = (preg_match($format, $value));
  12.  
  13. print "$match\n";
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
1