This literally means 'to complete, finish' but can (and usually does) involve a regret over having done something. Also it can be used sarcastically to mean the speaker really wanted to do something, but gives a halfhearted apology. For example, 最後のクーキーを食べてしまった。 I unfortunately ate the last cookie. Of course there really wasn't anything unfortunate about it.
The construction is usually after the ~te form of any verb
zenbu no okane o tsukatte shimaimashita.
Unfortunately, I spent all my money.
watashi wa kanzen ni nihongo o wasurete shimatta.
Unfortunately, I have completely forgotten Japanese.
Another very useful variation is ~chatta. This is informal and is used by both male and female speakers. chau is made by combining te shimau -> chau
shiken ni ochichatta.
I flunked the test unfortunately.
or in the present tense
ke-ki o zenbu tabechau.
I will eat all the cake.
An important point by Mukade in the forums:
In the Kansai area, the use of ちゃった is limited to female speakers.
I learned both in the classroom, of course, since they are standard dialect. But when I moved here to Osaka, people started asking me if I was gay, since I kept using ちゃった all the time.
If I could help prevent someone else from having to go through the same "hard knocks" learning process that I did, it would make me very happy.
So be careful if you are in the Kansai area! But in most areas it should be fine.