I'm new to electronics and was wondering what was the difference between a Mosfet and a voltage regulator?
MOSFETs and voltage regulators often come in similar-looking packages and usually have 3 pins each, but their functions are different.
A voltage regulator takes in a high voltage, like 12 V, and puts out a lower voltage, like 5 V. The canonical example of a voltage regulator is the LM7805. They tend to be fairly inefficient (some of the power is lost as heat).
A MOSFET is a semiconductor switch. It varies the resistance between two pins in response to a voltage on a third pin. Inside the MOSFET, the voltage on the third pin (the gate) pulls electrons into a narrow path between the other two pins (the source and drain), allowing electricity to flow. Here's a decent diagram.
In very basic terms, a voltage regulator is a device for building a power supply, whereas a mosfet is something you use to build an amplifier. A voltage regulator is basically an integrated circuit that has several transistors within it, while a mosfet is exactly a single transistor.
A MOSFET is a single transistor that will be able to provide a regulated voltage if used inside of a whole voltage regulator circuit (or IC). To build a (linear) voltage regulator, one needs a pass element (regulated "valve", e.g. MOSFET or biolar transistor), a voltage reference and a circuit that compares the desired, regulated output voltage to the reference voltage and adjusts the pass element such that the output will remain in regulation.
Thus, a MOSFET may act as one part inside of a voltage regulator.