Changed preg_replace delimeter to ~