I am facing a challenge with a JavaScript string that contains contact information that needs to be filtered. For example, I want to mask any email or phone number in the message.
I have attempted the following approach:
function(filterMessage) {
var maskedMessage = filterMessage.replace("/^([\da-z_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/", "<MaskedEmail>");
return maskedMessage;
}
Unfortunately, this method is not producing the desired results.