What Cy-Pres Doctrine means is that the courts will try and find a general testamentary intentioned to benefit a charity. If that charity has been misdescribed in your will, the courts will try and find another charity of a similar fashion and intention to instead inherit.
For example, in Vancouver, everyone seems to think that there’s an entity known as Children’s Hospital. It is commonly used in verbiage but it does not legally exist. So if a will is written leaving the assets to a charity such as Children’s Hospital, and the charity has been misnamed, the courts will try and put their self in the position of the testator to find out what the true intention was in benefitting a particular charity and find a substitute charity to instead benefit.