どうですか:
$files = array(
'COMPANY_DE-Actual-Contents-of-File-RGB-ENG.pdf',
'COMPANY_BE-Actual-Contents-of-File-CMYK-ENG.pdf',
'COMPANY_DE-Actual-Contents-of-File-PMS-GER.doc',
'COMPANY-Actual-Contents-of-File-PMS-GER.doc',
'COMPANY-Actual-Contents-of-File-GER.doc',
'COMPANY-Actual-Contents-of-File.doc',
);
foreach($files as $file) {
preg_match('/^(?<COMPANY>.*?)_?(?<LOCATION>DE|BE)?-(?<CONTENT>.*?)-?(?<COLOR>RGB|CMYK|PMS)?-?(?<LANG>ENG|GER)?\.(?<EXT>[^.]+)$/', $file, $m);
echo "\nfile=$file\n";
echo "COMPANY: ",$m['COMPANY'],"\n";
echo "LOCATION: ",$m['LOCATION'],"\n";
echo "CONTENT: ",$m['CONTENT'],"\n";
echo "COLOR: ",$m['COLOR'],"\n";
echo "LANG: ",$m['LANG'],"\n";
echo "EXT: ",$m['EXT'],"\n";
}
出力:
file=COMPANY_DE-Actual-Contents-of-File-RGB-ENG.pdf
COMPANY: COMPANY
LOCATION: DE
CONTENT: Actual-Contents-of-File
COLOR: RGB
LANG: ENG
EXT: pdf
file=COMPANY_BE-Actual-Contents-of-File-CMYK-ENG.pdf
COMPANY: COMPANY
LOCATION: BE
CONTENT: Actual-Contents-of-File
COLOR: CMYK
LANG: ENG
EXT: pdf
file=COMPANY_DE-Actual-Contents-of-File-PMS-GER.doc
COMPANY: COMPANY
LOCATION: DE
CONTENT: Actual-Contents-of-File
COLOR: PMS
LANG: GER
EXT: doc
file=COMPANY-Actual-Contents-of-File-PMS-GER.doc
COMPANY: COMPANY
LOCATION:
CONTENT: Actual-Contents-of-File
COLOR: PMS
LANG: GER
EXT: doc
file=COMPANY-Actual-Contents-of-File-GER.doc
COMPANY: COMPANY
LOCATION:
CONTENT: Actual-Contents-of-File
COLOR:
LANG: GER
EXT: doc
file=COMPANY-Actual-Contents-of-File.doc
COMPANY: COMPANY
LOCATION:
CONTENT: Actual-Contents-of-File
COLOR:
LANG:
EXT: doc