Does it have to be a regex? If not:
$daysStart = 'Mon,Tues,Wed,mon';
$days = strtolower($daysStart);
$days = explode(",", $days); // split on comma
$days = array_unique($days); // remove uniques
$days = implode(",", $days); // join on comma
// Compare new string to original:
if(strtolower($days)===strtolower($daysStart )){ /*match*/ }
This results in a lowercase string of days, seperated by commas. Not sure what you wanted as output, you might want to save the original input in another far, or ucfirst()
the values via an array_map()
or something, this is just to show you another method
Or my code shorter:
$daysStart = 'Mon,Tues,Wed,mon';
$days = explode(",", strtolower($daysStart ) );
$days = implode(",", array_unique($days) );
if(strtolower($days)===strtolower($daysStart )){ /*match*/ }
or function (as short code, can be the longer version ofcourse):
function checkDays($string){
$days = explode(",", strtolower($string) );
$days = implode(",", array_unique($days) );
return (strtolower($days)===strtolower($daysStart)) ? true : false;// *
}
*I could've done just the return and the str-checks, but I prefer to add true/false in a way im sure my returnvalue always is true of false as boolean, not truthy or falsy.