Skip to content

Instantly share code, notes, and snippets.

@javifr
Created April 13, 2016 10:10
Show Gist options
  • Save javifr/08ee7fd571d4e58c741e644ad8167489 to your computer and use it in GitHub Desktop.
Save javifr/08ee7fd571d4e58c741e644ad8167489 to your computer and use it in GitHub Desktop.
Regexp to slugify a string field
select XXXX , regexp_replace(
translate(
replace(lower(replace(lower(replace(lower(replace(lower(replace(lower(replace(lower(YOURFIELDNAME), 'ñ', 'n')), 'º', 'o')), 'ª', 'a')), 'ç', 'c')), '-', '_')), ' ', '_'), 'áàâãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóòôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮ','aaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuu'
), '[^\w -]', '', 'g')
from YYYYY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment