Thanks Skeeve. But this seems not work for very large DNA. You also didn't do anything with the stop codons. when I ran it using a large DNA, there were subsequences having non-stop codons at the end of the string.
The basic idea is:
find all start codons(in this case ATG,GTG,ATT, GTC, CTG)
find all stop codons(basically 3 of them; TAG, TAA, TGA)
find all possible subsequences in between starts and stops and keep these in an array(with the start and stop codons inclusive).
then translate the contents of the array to proteins
Cheers