Completly remove the regex in favor of simple php functions calls