$re = '/^(AN|AA|AD|AE).*?(Jan|Feb|Mar|Apr|May|Jun|JUL|Aug|Sep|Oct|Nov|Dec)*([a-z]{3})([a-z]{3})|^FXD.*?([a-z]{3})([ ]*\/[ ]*[d,D]\d\d\w\w\w|[ ]*\/[ ]*[t,T][d,D]\d\d\d\d)*([a-z]{3})*([ ]*\/[ ]*[d,D]\d\d\w\w\w|[ ]*\/[ ]*[t,T][d,D]\d\d\d\d)*([a-z]{3})*/mi';
$str = 'fxdbom /d12augdel
FXD 4 JFKMIA
FXDJFK/ D15JUNMIA /D25JUNATL/D27JUNJFK
FXDJFK/D15JUN/TD0900MIA
FXD 2 PAR /D15JUNMIA //PB2500
FXD BOM /D12AUGDEL /D23SEPBOM
FXD BOM /D23AUGDEL /D24SEPBOM';
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