Skip to content

Instantly share code, notes, and snippets.

@jeanphix
Last active October 10, 2017 17:17
Show Gist options
  • Save jeanphix/298735adc4cff303912860685a9324ca to your computer and use it in GitHub Desktop.
Save jeanphix/298735adc4cff303912860685a9324ca to your computer and use it in GitHub Desktop.
create extension if not exists "unaccent";
create or replace function slugify(name text)
returns text as $$
begin
return trim(
regexp_replace(
unaccent(lower(name)),
'[^0-9a-z]+',
'-',
'g'
),
'-'
);
end; $$
language plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment