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

     [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] 


   Organization 3

  [email protected] [email protected]  

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

     [email protected]


   Organization 3

  [email protected]
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 = "[email protected] [email protected] [email protected],  [email protected] [email protected] [email protected] [email protected]";

    var emailInArray = emailIds.split(' ');

    console.log(emailInArray[0]) //[email protected];
Sridhar
  • 128
  • 1
  • 10