Last active
April 7, 2024 12:29
-
-
Save Jonathan-49/72e1b615e3e395e2b4cf14b4051b1b6d to your computer and use it in GitHub Desktop.
Obscure_emailaddress
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
-- https://www.rpgpgm.com/2024/01/sql-repeat-scalar-function.html | |
-- IBM Db2 for i | |
SELECT EMAIL_ADDRESS, | |
SUBSTR(EMAIL_ADDRESS, 1, 1) || | |
REGEXP_REPLACE(LOWER(SUBSTR(EMAIL_ADDRESS, 2, | |
(LOCATE_IN_STRING(EMAIL_ADDRESS, '@') - 2))), | |
'[a-z]|[0-9]|[._]', 'x') | |
|| SUBSTR(EMAIL_ADDRESS, LOCATE_IN_STRING(EMAIL_ADDRESS, '@')) | |
FROM TESTFILE; | |
-- An alternative method | |
SELECT EMAIL_ADDRESS, | |
SUBSTR( EMAIL_ADDRESS, 1, 1) || | |
repeat('x', LOCATE_IN_STRING( EMAIL_ADDRESS, '@') -2) || | |
SUBSTR( EMAIL_ADDRESS, LOCATE_IN_STRING(EMAIL_ADDRESS, '@')) | |
FROM TESTFILE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment