Created
June 13, 2018 03:01
-
-
Save fdidron/dd736864c21ff6ddc777a1a337a6a216 to your computer and use it in GitHub Desktop.
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("value" TEXT) | |
RETURNS TEXT AS $$ | |
SELECT regexp_replace( | |
trim( | |
lower( | |
regexp_replace( | |
unaccent("value"), | |
E'[^\\w\\s-]', | |
'', | |
'gi' | |
) | |
) | |
), | |
E'[-\\s]+', '-', 'gi' | |
) FROM "normalized"; | |
$$ LANGUAGE SQL STRICT IMMUTABLE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment