, you are - of course - right with your remark that regular expressions aren't always the answer.
It really depends on the problem. If a special named file should be removed from the array then
is probably the better solution.
should be removed, then a regex might be the way to go.
Since there is no information about the general problem in the OP we are left guessing.