Extract email please

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

    DJM4@gmail.com:marakkakaka —“last_name”: “Dharmani”
    Da89@gmail.com:qwsgshs “uid”: 14429319
    Deney3536@gmail.com:al4rtey @asnbncbnabsnm



    please I need your help, eternally grateful

  • @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.


  • eternally thank you my friend

Log in to reply