Extract the middle names and last name from the string using regex of Javascript

I need to extract the middle and last names

Elev: 7EBB49 (Dan Greg Järgenstedt <dan.greg.smith@manu.al.edu>)
Expected: Greg Järgenstedt

Elev: 6EBB49 (Dan Järgenstedt <dan.greg.smith@manu.al.edu>)
Expected: Järgenstedt

Elev: 6EBB49 (Järgenstedt <dan.greg.smith@manu.al.edu>)
Expected: Järgenstedt

Elev: 6EBB49 (<dan.greg.smith@manu.al.edu>)
Expected: 

Tried with

function getSNames(input) {
    const names = input.match(/(?<!\[)(?<=\s)\w+(?=\s)/g);
    return names ? names.join(' ') : '';
}


from Recent Questions - Stack Overflow https://ift.tt/2Jgiwod
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept