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

  • SEARCH
  • Home
  • 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

Probably an easy one: Are there any rules of thumb or pointers that could
There is one thing that I do not understand... Imagine you have a text
Simple question, but one that I've been curious about...is there a functional difference between
I noticed that there is one change about ASP.NET Routing. I cannot understand why
When there are one of more columns that reference another, I'm struggling for the
When running any kind of server under load there are several resources that one
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Is there a tool that allows one to monitor GDI calls?
I've heard that there are some things one cannot do as a computer programmer,
Is there a quick tcpdump one-liner to print out a TCP stream that matches

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.