$re = '/\s+[Aa]\d*\s+Sheet/';
$str = ', I want to extract A040 to excel collumn next to the filename.
Before the A040 there is always three empty spaces and than text Sheet (also in screenshoot) A040 Sheet
Every file has different number and there is always letter A with three digits and text Sheet. --> example file uploaded: A040 Sheet
I has something already in VB with Excel but it is not working. A040 Sheet';
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