i’m quite newbie about regex i’m trying to replace 2 or more commas to one and deleting the last comma.
$string1= preg_replace('(,,+)', ',', $string1);
$string1= preg_replace('/,([^,]*)$/', '', $string1);
my quesiton is: Is there any way to do this with a single line of regex?
Yes, of course that’s possible: