1 - Yes, the regex works fine, but so does all of the code. I.e., I see nothing wrong with the context, but maybe I'm not grokking something. I threw parentheses around the *{4}filename.ext*{4} portion of the regex and it was stored in the array properly, too.
2 - Perhaps maddfisherman was looking in $template1 instead of $template[0] ?