Voltage regulation and current limiting with a microcontroller
To replace R2 you can use a digital potentiometer or "digipot". It acts like a resistor where the resistance can be controlled over a digital bus such as SPI. It might also work for R3 but I'm not sure how much current it has to carry; if it's small a digipot would work there as well of course.

A switching approach might be smarter though, since it would be cheaper and more efficient although more complicated to design.