coryd.dev/queries/functions/parse_country_field.psql

14 lines
371 B
Text

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