Sure I'll do it in bits for you, there's a good variety of regex bits in it..
The first line means do a match on the string $filename and save the bit it matches for later use.
This is the regex:
The parentheses ()
, mean save everything matched in the variable $1 so that it can be used later.
The square brackets mean a character class, i.e. a selection of characters, so that [aeiou] would match one single vowel.
A caret ^
at the very beginning of a character class means that the character class is negated, so that [^aeiou] would match anything that isn't
a vowel - i.e. any one consonant.
Inside the actual character class there's basically just a forward slash and a backward slash.. but because these are both special characters they have to be preceded by a backslash themselves in order to actual match.
The + means match one or more of whatever precedes it - i.e. anything that isn't a forward or backward slash.
The $ at the end of the string means match the expression at the very end.
So all in all it means this: match one or more non
-slash character at the end of the string, i.e. everything after the last slash.
I've made it sound a lot more complicated than it is.. hope I helped anyway.