Thank you for taking the trouble to use code tags, this time.
Now, perhaps, you'll continue your evolution toward one who posts questions which make it easy for us to help.
- "pattern matching is working for one occurrence."
Which one? Is there an error message? If so, post it, verbatim. You need to specify your problem (and that may be something in your data, so you should post a small sample of that, too.
- "Could you please guide me where i am going wrong."
Aside from the fact that that sentence should end with a question mark, it misses the mark as an SOPW question because you don't tell us what is "going wrong" which leaves us to guess. At best, that's an inefficient way for you to learn.
As noted in a previous reply (in another thread), please plainly mark any edits/updates you do.