I could of slapped you around a bit with a large trout after seeing your question.
You have hundreds of posts on here with similar code, and some very experienced code in terms of using $regex and such like, for you to post that question is such a waste of bandwidth on these forums, In terms of so many people doing it. but oh well
didn't need an 'm'