What will be the best way to express the feeling when you hear that your colleague is leaving the job.
What you should do is dictated by your local culture/norms. In some places there is a small get together with cake + refreshments; in others there is a formal ceremony; yet some places just have a card + signatures.
No matter where you are, try to at least cover these areas in your approach/farewell - within the norms of your culture/establishment:
- Congratulate/thank them for their time with you.
- Wish them good fortune/best of luck etc. in their future endeavors.
- Ask them if you can add them to your linkedin to keep in touch. Very important, as you don't want to burn bridges. Replace linkedin with whatever suits your environment - I prefer linkedin as its not a wild wild west situation like facebook.
That's about it.
If you are unhappy about their departure (for example, if this means you have to do extra work/hours/shift or train their replacement, etc.) this is not the time to bring that up; you should discuss this in private with your management/HR after the person has departed amicably.
Your question is rather vague. You don't indicate who you're concerned about expressing yourself to, or a time frame. Nor do you indicate in any way in the question how you truly feel about the colleague leaving. It's normal to feel confused, angry, betrayed, relieved, excited, nervous, happy, and many other things too. Let me give you some suggestions.
- at the instant someone tells you for the first time "I was just fired" or "I have decided to take another job" the only culturally appropriate response is surprise. If you happen to like the person, then an aligning statement ("oh man, how could they fire you?" or "it sounds like you've found a great job, congratulations my friend") can be added. Essentially something that puts yourself "on their side" without actually doing anything about it.
- at the instant someone else tells you for the first time "Steve will be leaving us on Monday" or "Steve doesn't work here any more" again surprise is appropriate. Curiosity is only appropriate if you are alone with the person who told you. In a group setting a muted response is always safest. Say very little. If you care a lot (whether positive or negative) you can seek out the leaving employee or the person who made the announcement for a one-on-one conversation to ask for details that are relevant to you
- during a person's leave notice, where everyone knows they're going but they haven't gone yet, you stay polite and professional even if you're very jealous of the opportunity they're getting, angry that they're leaving you to finish something, can't wait to take over from them as lead, can't wait till you don't have to see them any more, or whatever. You say out loud that you wish them the best of luck and hope everything works out great for them in the new position. You may discuss with management or leads how some practicalities will work out - who will do specific tasks next week that the leaving person is doing this week, that sort of thing.
- once the person is gone, it is rarely useful to say to others that you miss the person nor that you are glad they are gone. Occasionally a mild or gentle comment like "morning meetings sure are faster these days" or other reference to how things were when the colleague was here may be appropriate.
If the person is a friend, the time between when you learn they are going and when they go can be quite awkward. Often, you may have mixed emotions yourself: angry that your friend was laid off, but relieved that you were not; or jealous of the great opportunity but proud of your friend for landing it; sad at the thought of having one less friend in the office, but excited about the new responsibilities you'll be taking on. Just go with the situation and don't try to resolve the mixed feelings. Do your best to express only positive feelings in group situations. One on one with your friend, only express sad feelings that are positive (I'll miss you) not those that are negative (I'm going to have so much more work to do because they're not replacing you.)
If the person is not a friend, don't overthink this. Do and say what the others around you do and say, no matter how you feel, and carry on about your job. Colleagues come and go, it's part of normal workplace life.
Offer them your heartiest congratulations and wish them all the best for the future! If they have been with the company for a long time, it can be appropriate and appreciated to have everyone write in a card wishing them all the best for their future endeavours.