Change replace callback to a named method

As noted in the PHP manual, create_function has issues with
performance and memory usage, since the functions cannot be
garbage collected. Here though, the change is mostly for
readability.
Tweak, clean and improve regexes.

They are now expanded with comments, more robust, less unnecessarily
escaped and includes a better check for attributes (though still not
really good enough).
Add filter alternatives to encoding methods
Update version to 2.5.0. Update documentation