Skip to content

Instantly share code, notes, and snippets.

@undernewmanagement
Forked from chanmix51/slugify.sql
Created April 10, 2012 03:56
Show Gist options
  • Save undernewmanagement/2348226 to your computer and use it in GitHub Desktop.
Save undernewmanagement/2348226 to your computer and use it in GitHub Desktop.
slugification in plpgsql
CREATE OR REPLACE FUNCTION slugify(title VARCHAR) RETURNS varchar AS $$
BEGIN
RETURN trim(both '-' from regexp_replace(lower(transliterate(title)), '[^a-z0-9]+', '-', 'g'));
END;
$$ LANGUAGE plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment