2020-10-29

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

No comments:

Post a Comment