Community
    • Login

    Regex mask a list of emails?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.1k Views 1 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors