Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
%%[
/* 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