Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Last active September 4, 2015 13:45
Show Gist options
  • Save chanmix51/331988 to your computer and use it in GitHub Desktop.
Save chanmix51/331988 to your computer and use it in GitHub Desktop.
slugification in plpgsql
CREATE OR REPLACE FUNCTION slugify(title VARCHAR) RETURNS varchar AS $$
SELECT trim(both '-' from regexp_replace(lower(transliterate(title)), '[^a-z0-9]+', '-', 'g'));
$$ LANGUAGE sql IMMUTABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment