DECLARE delimiters TEXT[] := ARRAY[',', '/', '&', 'and']; countries TEXT[]; result TEXT := ''; BEGIN countries := string_to_array(countryField, ','); FOR i IN 1..array_length(delimiters, 1) LOOP countries := array_cat(countries, string_to_array(result, delimiters[i])); END LOOP; result := array_to_string(countries, ' '); RETURN trim(result); END