$re = '/(?=.{10}$)(?=.*[A-Za-z]){2,}(?=.*[0-9]){2,}(^|\s)[A-Za-z0-9]{10}($|\s)/m';
$str = 'AB1234567
09AR30253
0912345JL
abc12464
12345678
AABBCCAA23
12345B645 13424db67
12AB32457 123as3456
AB123456
123as3456 -123as3456 kljl
1B5W90R0 1B5W90R0 1B6-KQ0R-0
stackoverflow
thisstackoverflow
this is stackoverflow
this is stackoverflow it
this is stackedoverflow
1B6-KQ0R-0
1B6-KQ0R-0
Good morning, 1B
Please close accounts
Arthur Battersby – 1B6-KQ0R-0
Shirley Earle – 1B5-W90R-0
Thank you, 1B6KQ0R0 1B5W90R0
Brianna Toth
Administrative Assistant T: (888) 778-0356
Raymond James Ltd.
www.DoreyWealth.com <http://www.doreywealth.com/>
Victoria T: 250.405.2429 #1000-1175 Douglas Street (in CIBC Building), Victoria, BC V8W 2E1';
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