In your original post, you would've been better to have said that you were having trouble getting the code to work, rather than asking if it was correct. A number of people have posted codes here asking if they were right, and just have been too lazy to test the codes themselves. This is what it looked like you were doing.

Now that we know differently, someone will probably be more than willing to assist you. I regret not being able to do so, due to my lack of knowledge regarding regex, which your code uses.