Mask Email in a specific format

dt.AsEnumerable().Where(Function(row) Not row(“c_email”).ToString.Equals(“”)).ToList.ForEach(Sub(row) row(“c_email”) = “**********”)

With reference to above post, I tried to mask the email data.
But we need to mask it in a particular format

Eg:abcdef1234@gmail.com should be masked as ab********@gmail.com
or xyz1234@yahoo.com should be masked as xy*****@yahoo.com

Only first letters & domain should be visible and rest should be masked
as shown in above example.

@MANISHA_V_ARORA - is this what you are looking for?? 3rd case, what if the 2nd character is a Number…??

image

Basically first two characters should be retained, no matter it is number or alphabets

Then change the regex pattern to [A-z1-9] in the beginning…rest of the thing remains as is…

@MANISHA_V_ARORA - Below pattern will take first characters irrespective of alphabets, numbers , symbols etc…

image

How do i add it here?

dt.AsEnumerable().Where(Function(row) Not row(“c_email”).ToString.Equals(“”)).ToList.ForEach(Sub(row) row(“c_email”) = “**********”)

@MANISHA_V_ARORA - As shown below…

dt.AsEnumerable().Where(Function(row) Not row(“c_email”).ToString.Equals("")).ToList.ForEach(Sub(row) row(“c_email”) = system.text.regularexpressions.regex.replace(row(“c_email”).tostring,"(?<=^.{2}).+(?=@)","*****"))

@MANISHA_V_ARORA - Did you get a chance to try??

Yes just tried now & it worked.

Thank You so much for your help…

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.