Gasoline internal combustion engines run at about 30% efficiency. Diesel does somewhat better at about 40% for car size engines, and about 50% for the really big ones. Electric motors easily exceed 90% efficiency. The EV wins even without regenerative breaking, even accounting for the losses in the batteries.
It's somewhat matched if the electricity is generated by combustion. Even then, if the power is generated using an efficient cycle (e.g. CCGT) the EV still tends to come out ahead.
40% diesel efficiency is for optimal conditions, like steady cruise on a motorway. For practical driving it is less than 25%.
What is also missing here is that it takes 20-30% of energy to refine diesel or gasoline plus there is oil extraction cost. Accounting for that electrical car produces less CO2 when electricity comes from a modern coal plant than a diesel car.