In a journey, i have a need to mask the email address (and phone) of the user. I wrote a javascript to do this but when invoking this in the journey i am getting an exception on the regex part of the script. Is there a way to run the below function, specifically the regex variable / replace) in AM?
//this will mask the email address value
function maskEmailAddress(mail) {
logger.error("Masking the email address with value: " + mail)
var rawUser, maskedUser, rawDomain, retMail
var regex = /(?<!^).(?!$)/g
rawUser = mail.split("@")[0]
rawDomain = mail.split("@")[1]
maskedUser = rawUser.replace(regex, "*")
retMail = maskedUser + "@" + rawDomain
logger.error("Returning the value for masked mail of: " + retMail)
return retMail
}
this script works in node / straight java script, but trying to find the right syntax for am script / rhino.
Thanks
Nick