Fix `ereg is deprecated` errors in PHP >= 5.3