-
-
Save undernewmanagement/2348226 to your computer and use it in GitHub Desktop.
slugification in plpgsql
This file contains 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 $$ | |
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