What the law actually says is that the final 18 months of ownership is always exempt from CGT, provided that the property has been the owner's principal private residence at some time. So, the period of rental must cover that final 18 months for that additional relief to apply, otherwise the whole 5 year rental period is chargeable. Assuming that the 18 month "bonus" is available, you have to first calculate the gain for the whole period of ownership, then deduct the proportion relating to the 26.5 years which are exempt. What is left may still not be taxable, because Lettings Relief of up to £40,000 is available.
The situation could be different if the owner is not resident in the UK at the time of sale.