Community
    • Login

    Regex mask a list of emails?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 716 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kraddockK
      kraddock
      last edited by

      Hey guys,

      In a list of emails (one per line), similar to this:

      Screen Shot 2023-06-19 at 11.18.01 AM.png

      How to use regex to mask the emails (for GDPR) by replacing every character between the first and last before @ with * ?

      So we get this:

      Screen Shot 2023-06-19 at 11.18.04 AM.png

      Or alternatively, just insert a set number of asterisks (for example, 5) after the first character and @, like this:

      Screen Shot 2023-06-19 at 11.18.07 AM.png

      I’ve been struggling with this the whole morning and got nowhere…

      Please help :(

      (images used because of Akismet marking the post as spam otheriwse)

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by

        Hello, @kraddock and All,

        • For your first goal, I propose this regex S/R :

          • SEARCH (?!^).(?=.*.@)

          • REPLACE *

        And you end up with this OUTPUT text :

        e****1@gmail.com
        s***********l@icould.com
        t********l@yahoo.com
        

        • For your second goal, I propose this regex S/R :

          • SEARCH (?!^).(?=.*@)

          • REPLACE *

        And you end up with this OUTPUT text :

        e*****@gmail.com
        s************@icould.com
        t*********@yahoo.com
        

        For each case, check the Regular expression search box !

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 3
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors