- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$s = "Example of valid matches: NE1, NE17, NE49 Invalid matches: NE61, NE70";
if (preg_match_all('~\bNE(?!(?:6[1-9]|7[01])\b)\d{1,2}\b~', $s, $matches)) {
print_r($matches[0]);
}