0

Scenario

Recently I extracted emails from 430 different html webpages of organizations with regex but some organizations had multiple emails and here's what the mess looks like

Input

   Organization 2

     info@something.org.au more@something.com market@gmail.com single@noidea.com human@myplace.com south@north.com darlings@mall.com 


   Organization 3

  headmistress@money.com head@skull.com  

What I want
The very first email of these organizations is the important email. Is there any way regex can select everything after the first whole word and I can use Notepad++'s "Replace All" to remove it?

Output(Something like this)

   Organization 2

     info@something.org.au


   Organization 3

  headmistress@money.com
Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

1

To get your expected output, use this pattern:

/^.*?@[^ ]+|^.*$/gm

Online Demo

Shafizadeh
  • 9,960
  • 12
  • 52
  • 89
0
  • step 1:
    first you have to keep all email address in a variable as string.
  • step 2:
    split your string to array
  • step 3:
    get your first email id based on array index.

check the example code below:

    var emailIds = "info@something.org.au more@something.com market@gmail.com,  single@noidea.com human@myplace.com south@north.com darlings@mall.com";

    var emailInArray = emailIds.split(' ');

    console.log(emailInArray[0]) //info@something.org.au;
Sridhar
  • 128
  • 1
  • 10