php - Filename regex extraction -
i'd parts of filename
filenameblabla_2009-001_name_surname-name_surname
i'd get: 2009-001, name_surname, name_surname
i've come this, it's no good
preg_match("/(?:[0-9-]{8})_(?:[a-z_]+)-(?:[a-z_]+)/", $filename, $matches);
any pointers?
thanks! br
assuming filename format doesn't change:
preg_match('#(\d{4}-\d{3})_(.*?)-(.*?)$#', $filename, $match);
updated version handle extension:
preg_match('#(\d{4}-\d{3})_(.*?)-(.*?)\.(.*?)$#', $filename, $match);
Comments
Post a Comment