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; |
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 transliterate(my_text VARCHAR) RETURNS varchar AS $$ | |
| DECLARE | |
| text_out VARCHAR DEFAULT ''; | |
| BEGIN | |
| text_out := my_text; | |
| text_out := translate(text_out, 'áàâäåáăąãāçċćčĉéèėëêēĕîïìíīñôöøõōùúüûūýÿỳ', 'aaaaaaaaaaccccceeeeeeeiiiiinooooouuuuuyyy'); | |
| text_out := translate(text_out, 'ÁÀÂÄÅÁĂĄÃĀÇĊĆČĈÉÈĖËÊĒĔÎÏÌÍĪÑÔÖØÕŌÙÚÜÛŪÝŸỲ', 'AAAAAAAAAACCCCCEEEEEEEIIIIINOOOOOUUUUUYYY'); | |
| text_out := replace(text_out, 'æ', 'ae'); | |
| text_out := replace(text_out, 'Œ', 'OE'); | |
| text_out := replace(text_out, 'Æ', 'AE'); |
NewerOlder