How to express the condolence to someone who lost somebody? Like for example a death of a husband or wife?
Mein herzlichstes Beileid.
Mein tiefes Mitgefühl.
are standard phrases for this situation. If you want more variety have a look at Trauerspruch.de. But these are mainly written condolences on that site.
Using pre-fabricated standard condolence phrases is... well, for some, it's probably a way of saying "I don't know what to say". But I think if it's heartfelt, you'll find something personal. Even if it's only "Scheiße. Es tut mir leid.".
If it's just a formality, on the other hand, go with John Smithers' suggestion of "Mein [herzliches] Beileid". That's the standard.
"herzliches" or even "herzlichstes" is not appropriate in this situation. Are you glad, that somebody died? I hope, your are not. So "Mein Beileid" is all you say at the funeral. And that's it. Nothing more, nothing less.
What does fzwo regret? Did he / she kill the person and rue the deed? I hope not, so "Es tut mir leid" is definitely inadequate. And certainly nobody wants to hear shit (Scheiße) during the ceremony.
Some of the phrases on Trauerspruch.de are really "kitschig". They might be appropriate writing a letter, but not while shaking hands before the church service.
So, keep to the standard "Mein Beileid" and everybody will know what you mean.