Role of diodes and capacitors in the voltage regulator
D1 and D2 just make sure that current will never flow into those regulators the wrong way. Sure there will be a ~0.7V drop across them but they're regulating down to 12V anyway.
It's common practice to put capacitors on the input and output of regulators, I just take values according to the datasheets. They will keep your input and output voltages steady, just a way of reducing ripple and noise. They're actually common practice to put on any IC power input as well, just to keep the power supply clean. That's why you'll see really small .01uF to 10uF caps all over PCBs nowadays.
Now to answer your question on regulating mains, this circuit will not do. Those ICs have an absolute max voltage input of 40Vdc according to the datasheet. You'll likely want a mains transformer to step the voltage down first to a more manageable level, and then put it through a rectifier, smooth with some caps, pass it into a regulator IC, and call it a day. Something like 
(source: circuitstoday.com)
Or if you wanted to go less efficient,you can slap a zener diode and resistor to clamp voltage (according to the reverse breakdown of the zener) and limit the current.