let us examine what this first argument for the gsub method, /.*\// means.
the first and last slashes /.../ denotes that we are dealing with a regex here, not string.
There are two parts to this regex. .* and \/.
.* says that grep any characters, including empty character.
\/ says that grep a string with a slash, /.
This regex would catch,
['/', 'Users/', 'user/', 'Desktop/', 'work/', 'arthouse/', 'digitization/', 'in-process/']
All these strings are now replaced with ''.
Except cat.jpg which doesn't have the slash at the end.
Hope that explanation helps.
In the second part, /(\w+)-(\d+)([a-z]?)/
(\w+): grep a group of word characters (includes numbers)
-: grep for a dash
(\d+): grep a group of numeric digits
([a-z]?): grep for nil char or a single char.
cat.jpg doesn't fit into this regex in many ways. No dash, . in the string. etc.
Therefore, scan will return an empty array.