Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Last active June 18, 2021 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zuzannamj/197b7f57868cd1a9dd54ef1a045704c2 to your computer and use it in GitHub Desktop.
Save zuzannamj/197b7f57868cd1a9dd54ef1a045704c2 to your computer and use it in GitHub Desktop.
%%[
/* pull the field to be masked from a data extension */
set @text = AttributeValue("email")
/* check the length of the string */
set @length = Length(@text)
/* count the number of characters to mask.
it also controls how many characters will not be masked.
currently set to 2, change to more if needed */
set @subtract = subtract(@length,2)
/* extract the string to be masked */
set @substring = Substring(@text,2,@subtract)
/* prepare a string of asterisks with the same length */
for @i = 1 to @length do
set @asterisks = concat(@asterisks,"*")
next @i
/* replace content of the original string with asterisks */
set @maskedText = replace(@text, @substring, @asterisks)
]%%
%%=v(@maskedtext)=%%<br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment