$re = '/(?<=a\/c|acc|account|ref|reference)\b\D+[0-9A-Za-z\-\\\\\/]+/im';
$str = 'My acc reference is 123456
My reference number is 123-456
My a/c reference number is 123-4556A
A/c number is 123-3456
This is another ref. number: 123/567-2B
cat and kitten both refer to cats.
He made reference in his novel to the 1929 census.
This data uses information from the financial year 1992/93 and also makes references to 90/91 figures.
The background property refers to a hexidecimal colour, H102567.
My a/c reference number is 123/456';
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