Last active
September 4, 2015 13:45
-
-
Save chanmix51/331988 to your computer and use it in GitHub Desktop.
slugification in plpgsql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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