Two possible ways. You might just learn how to represent, say, OR and AND gates with NANDS, and then replace every occurrence of ORs and ANDs with this implementation. But it might lead to a non-optimal solution. The second approach would be to use Boolean algebra and convert your expression to the representation suitable for the specific gate used. In your example:
f=(a+b')(cd+e) = (a'b)' ((cd)'e')'.
Now you need only know how to implement the NOT gate with NAND, and implement the expression as is, since the only operations are AND/NAND and NOT.
The most useful boolean algebra rule to use here is Da Morgans laws which state:
A'+B' = (AB)' (Voila! Couple of NOT's and OR are turning NAND!)
A'B' = (A+B)' (Couple of NOT's and AND are turning NOR!)