I would like to capture the last folder in paths without the year. For this string path I would need just ‘Millers Crossing’ not ‘Movies\Millers Crossing’ which is what my current regex captures.
G:\Movies\Millers Crossing [1990]
preg_match('/\\\\(.*)\[\d{4}\]$/i', $this->parentDirPath, $title);
How about
basename[docs] andsubstr[docs] instead of complicated expressions?This assumes that there will always be a year in the format
[xxxx]at the end of the string.(And it works on *nix too ;))
Update: You can still use
basenameto get the folder and then apply a regular expression: