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 7588701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:59:14+00:00 2026-05-30T19:59:14+00:00

I am using regex function to get the email address from the string. The

  • 0

I am using regex function to get the email address from the string. The email address is inside the string covered both side with different characters like.

string=:'Here is the email address I would like to get out of here Ahmad_khalid@yahoo.com in 1 st try'

This following syntax returns email address but miss the Capital characters and returns email address from about string like [hmad_khalid@yahoo.com] capital A is missed.

$regex='`([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})`';
  • 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-30T19:59:15+00:00Added an answer on May 30, 2026 at 7:59 pm

    I didn’t check your regex in detail, but if the capital characters are the only problem, then just add the i modifier after the last regex delimiter

    $regex='`([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})`i';
    

    this modifier makes the regex match case insensitive.

    OK, then you should add at least some anchors \b to the regex, to avoid partial matches.

    $regex='`\b([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})\b`i';
    

    See it here on Regexr

    The \b matches on a change from a word character (A-Za-z0-9_) to a non-word character (all the others) and the other way round.

    You should think about changing the last quantifier from {2,4} to {2,6}, there are some rare domains that are longer than 4 characters.

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

Sidebar

Related Questions

How do I get the percentage and filesize from this sort of string using
Trying to get this form to validate email using the function the professor said
im new with regexp, so can i ask for some assistance Using string.replace function
i want to check 2 patterns using regex. can i check those both patterns
Using regex. trying to get only the last x digits of the number and
I am trying to extract information from a tags using a regex, then return
I'm using JQuery to get values from a form. When I submit the form
I found a nifty RegEx function that I'm using (see below). The function outputs
I'm using a function to read specific query string variables and strip them of
Based on this answer... Using a regular expression to validate an email address Which

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.