Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3211862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:46:42+00:00 2026-05-17T14:46:42+00:00

If there is one that could handle this, what would be the correct regex

  • 0

If there is one that could handle this, what would be the correct regex pattern to extract email addresses from a string coming from an email form “To” line, that allows the addresses to be delimited by commas “,”, semicolons “;”, spaces, or any combination of the three. The regex also has to be able to ignore “noise” text, such as if an address is enclosed in “<” and “>” characters, or has an actual name next to the email address. For example, from this string that was in the To field:

"Joe Smith" <jsmith@example.com>, kjones@aol.com; someoneelse@nowhere.com mjane@gmail.com

The pattern should be able to return the following matches of:
jsmith@example, kjones@aol.com, someoneelse@nowhere.com, mjane@gmail.com

I am using PHP, so if this can’t be done in single regex then im definitely open to other PHP-based solutions.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T14:46:43+00:00Added an answer on May 17, 2026 at 2:46 pm

    Try

    \b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b
    

    (courtesy of RegexBuddy) as in

    preg_match_all('/\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b/i', $subject, $result, PREG_PATTERN_ORDER);
    $result = $result[0];
    

    Note the /i modifier to make it case-insensitive.

    See also this question for an explanation of the drawbacks of regexes for finding e-mail addresses in a string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many questions like this but I can't find one that seems to
I have multiple datasets that I would like to combine into one. There is
I realise there might be similar questions but I couldn't find one that was
There is one thing I never understood about references and I hope that one
I'm trying to implement invitations with Game Center and there's one thing that i
In a system I am currently working on, there is one process that loads
There's one specific feature that I wish was in the .NET framework, but isn't.
It seems that there are several really fast prime factorization algorithms around (one that
Is there one method or property in the .NET Framework that tells if an
In the code there exists exactly one type that implements IResourceConverter. That's what the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.