Please, TellTheDetails. What is the error? (by 'error', do you mean compilation error? in that case, a single line of code won't help us to figure out the actual problem)
Also, during pattern matching, (at least I) follow the process of 'starting with small' - e.g. firstly, make the code working with '.' in the string, then make it working with .cpp, and then go for multiple extensions.
Just providing a few lines of code and firing off vague questions like "I have a doubt about..." or "I think there's some problem, but..." gives the impression that you:
(a) Haven't bothered to read the tutorials (or the requisite material for your class).
(b) Haven't made an effort to at least try some solutions yourself.
(c) Want someone else to do your work for you.
Now all of the above may be false, but you need to learn to ask precise questions to avoid giving that impression.
My advice: After you've read our page, have a look at this one and this one. The first contains several excellent tips on how to formulate questions properly, particularly ones that involve programming code, and the second is a great general guide to asking question on sites like ours.
Remember: It's the policy of this site not to just "hand out answers".
Isn't it funny how there's always time and money enough to do it WRONG?
According to 1 line of code you have given it will give "illegal escape character" error at compile time. And this error occurs if you attempt to use backlash before a wrong character where it shouldn't be.