Want to remove multiple commas [with or without spaces] with a single one. Tried this regex however it failed preg_replace("/\s{1,5},\s{1,5}+/", ", ", $string);
Tried other solutions but can't find any solution where space also exists with comma.
Sample input个
GUWAHATI, TEZPUR, , BAMUNI HILLS, MAHABHAIRAB TEMPLE, AGNIGARH ,
GUWAHATI, TEZPUR , , BAMUNI HILLS,, MAHABHAIRAB TEMPLE, AGNIGARH,
GUWAHATI, , TEZPUR, , BAMUNI HILLS, MAHABHAIRAB TEMPLE, AGNIGARH
Expected output个
GUWAHATI, TEZPUR, BAMUNI HILLS, MAHABHAIRAB TEMPLE, AGNIGARH