I can paraphrase the rule as: if you live in a house 2 years out of last five years, you will enjoy SOME or ALL of the primary residence capital gain exclusion.
If you lived in a home first for 2 years, and rent for three and sold before 5 years anniversary, the 500K of the capital gain is tax free. THis is true. That's the example in the article.
But that doesn't mean you can enjoy FULL exemption if you live in the house for ANY 2 years out of five. If you first rent a house for three years and then live in it for 2 years, only 2/5 of the capital gain could be tax free.
Essentally, the rule just means if it is your home, IRS gave you three years grace period after you move out to enjoy FULL capital gain exemption. Because during those three years you might find out the new house, new job and new city doesn't fit you and you could go back to your previous home; or you couldn't sell the house immediately due to a down market and you had to rent it out to wait for a better market.