• Login
Community
  • Login

Extract email please

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 1.1k 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.
  • R
    rovitie
    last edited by Apr 26, 2019, 2:21 AM

    I have text file with 1000 lines. I wanted to extract those emails example:

    Clauhoff@googlemail.com :Po675e9979;gsgsgs@gmail:7373739,vscsx45@hot.com:hdbxscv
    Cocris@gmail.com:123qw,bxcsdrt@google.com:93edfhj;ncbdvrte@chamail.mx:23edfg
    Cons@gmail.com :qweqwe;bxadser@google.com:65edfhj,ncvcbdfte@chamail.mx:85yrtfg
    DJM4@gmail.com :marakkakaka —“last_name”: “Dharmani”
    Da89@gmail.com :qwsgshs “uid”: 14429319
    Deney3536@gmail.com :al4rtey @asnbncbnabsnm

    to

    Clauhoff@googlemail.com :Po675e9979
    Cocris@gmail.com:123qw
    Cons@gmail.com :qweqwe
    DJM4@gmail.com :marakkakaka
    Da89@gmail.com :qwsgshs
    Deney3536@gmail.com :al4rtey

    please I need your help, eternally grateful

    1 Reply Last reply Reply Quote 0
    • T
      Terry R
      last edited by Apr 26, 2019, 3:02 AM

      @rovitie said:

      wanted to extract

      I see from your small number of examples that there appears to be a number of different delimiters, namely ;, and space character. My regular expression has catered for these, however if there are others you will need to add them. I will show you where.

      So the Replace function is used
      Find What:(?-s)^(.+?:[^;, ]+).+
      Replace with:\1

      This is a regular expression so the search mode is ‘regular expression’. You can click once on the ‘replace all’ once setup and it will work on the entire file.

      By way of explanation:
      (?-s) means we only operate on 1 line at a time.
      The first ^ refers to the start of the line.
      Everything inside of the () is what we keep and \1 in Find What refers to that.
      .+?: means take as few characters as possible up to the first : character and together with the [] contents means we capture exactly what’s needed.
      [^;, ]+ means capture characters so long as we don't encounter one of the following, ;, or space. So if you have any further delimiters you need to place them inside of the [].
      The final .+ captures the rest of the line and since it’s not inside the `() it is lost/deleted.

      So for me it worked exactly as you requested on the examples provided. So it’s only as good as the data you provided. Any deviation or exceptions in your data will likely cause a bad result.

      Terry

      1 Reply Last reply Reply Quote 3
      • R
        rovitie
        last edited by Apr 26, 2019, 4:50 AM

        eternally thank you my friend

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