If you need a high quality linear regulator, an op amp can save a lot of effort. In the following demo, you can see that there is a simple zener shunt regulator connected to the positive input of the op amp. This becomes the reference voltage. If the zener is a 6.2 volt device, the reference will be 6.2 volts. Actually the reference voltage will likely be a little more or less than 6.2 volts (due to tolerances and the actual current flowing through the diode). If the voltage is precisely 6.2 volts on the positive input, the output of the regulator (the emitter of the current boost NPN bipolar transistor) will be precisely 6.2 volts. The feedback line from the emitter to the negative input of the op amp allows the op amp to monitor the output and compensate for changing load current. If the load resistor decreases in resistance, the output current increases (because we have a regulated voltage source). Without the feedback, the output from the regulator would likely drop a little. In most cases that would be fine. In some circuits, however, the change in voltage would be unacceptable.
When you push the button in the following demo, the resistance will decrease. You will notice that the regulator output current through the resistor increases in proportion to the fall in resistance. You will also notice that the output voltage is rock solid. If you look carefully, you can see that the output voltage from the op amp increases slightly to increase the current through the base of the transistor (which is needed to maintain the proper output voltage).