I currently use this piece of code to reduce a given text to a valid "tagging" format (only lowercase, a-z and minus allowed) by removing/replacing invalid characters
$zip_filename = strtolower($original);
$zip_filename = preg_replace("/[^a-zA-Z\-]/g", '-', $zip_filename); //replace invalid chars
$zip_filename = preg_replace("/-+/g", '-', $zip_filename); // reduce consecutive minus to only one
$zip_filename = preg_replace("/^-/g", '', $zip_filename); // removing leading minus
$zip_filename = preg_replace("/-$/g", '', $zip_filename); // remove trailing minus
Any hints on how to put at least the regex into a single one?
Thanks for any advice!