Skip to main content

Extract just name portion from a string

Comments

1 comment

  • Pankaj Kumawat

    Hi @Shilpa

    You can use this formula for retrieving the email id from the above mentioned String.

    const str = "John Doe <john@gmail.com>";
    const match = str.match(/<([^>]+)>/);

    if (match) {
      match[1];
    } else {
      "No email found";
    }




    Also, if this fails to retrieve email id from the string then it will say "No email found". So you can handle next steps based on the "if" condition as per your needs.

    0

Please sign in to leave a comment.