The actual problem with your regular expression is that it doesn't match what it's supposed to match. To break it down:
.*/ – any character, multiple times, followed by a slash. This basically consumes the directory list before the actual file name, so it'd literally match
./ (as in your example), but also
./some/other/dir/, up until the last slash.
This works because regular expressions are "greedy" by default, meaning that they match as much as they can. In essence, this part allows you to just search for the actual file name and strip the path from the result.
To summarize, you need the
.*/ in front of the regex if all you care about is the actual file name. If you need to match some parts of the path to the file as well, you cannot use
s_ – this works just fine in your example
[a-zA-Z] – this only consumes one character from this class
_ – followed by an underscore
[a-zA-Z] – again followed by one character
\.png – literally match the dot and the extension
So, you have to change your regex to:
You'll have to use the
+, which basically says, one or multiple of the previous.