PROV-940 Added some sanity checks

We now make sure the replacement configuration is valid (and give some
proper hints if it isn’t) before we throw it into preg_replace. Also
added a lengthy comment where I tried to describe the feature.
Merge branch 'develop' of github.com:collectiveaccess/providence into develop