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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:45:26+00:00 2026-06-17T02:45:26+00:00

I have never really studied regex so do not really ungerstand it I have

  • 0

I have never really studied regex so do not really ungerstand it

I have the following regex expression that tests email addresses

^([\\w]+)(\\.[\\w]+)*@([\\w\\-]+\\.){1,5}([A-Za-z]){2,4}$

when i enter example@example.cat it fails but when i enter example@example.com it works… can anyone explain why this is?

EDIT

Have been looking into the code and would this regex fail for the above email addresses?

^\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,6}$
  • 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-06-17T02:45:27+00:00Added an answer on June 17, 2026 at 2:45 am

    That regexp will not fail for .cat but match .com you must have something other issues causing the behavior you are seeing, here is an explanation of the regex:

    ^([\w]+)(\.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/
    
    ^ Start of string
    
    1st Capturing group ([\w]+) 
    Char class [\w] infinite to 1 times matches one of the following chars: \w
    \w Word character [a-zA-Z_\d] 
    
    2nd Capturing group (\.[\w]+) infinite to 0 times 
    \. Literal .
    Char class [\w] infinite to 1 times matches one of the following chars: \w
    \w Word character [a-zA-Z_\d] 
    @ Literal @
    
    3rd Capturing group ([\w-]+\.) 5 to 1 times 
    Char class [\w-] infinite to 1 times matches one of the following chars: \w-
    \w Word character [a-zA-Z_\d] 
    \. Literal .
    
    4th Capturing group ([A-Za-z]) 4 to 2 times 
    Char class [A-Za-z] matches one of the following chars: A-Za-z
    
    $ End of string
    

    And the second will also accept both given the right escaping (in most languages the double backslashes would cause both not to match):

    /^\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,6}$/
    
    ^ Start of string
    
    \w Word character [a-zA-Z_\d] 
    Char class [-._\w] infinite to 0 times matches one of the following chars: -._\w
    \w Word character [a-zA-Z_\d] 
    \w Word character [a-zA-Z_\d] 
    
    @ Literal @
    
    \w Word character [a-zA-Z_\d] 
    Char class [-._\w] infinite to 0 times matches one of the following chars: -._\w
    
    \w Word character [a-zA-Z_\d] 
    \w Word character [a-zA-Z_\d] 
    
    \. Literal .
    
    \w 6 to 2 times Word character [a-zA-Z_\d] 
    
    $ End of string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never really used regular expressions all that much and as such i
Ok I have this problem that I've never had before, it's really bugging me.
I have a rather complicated scenario that I have never really had to deal
http://pastebin.com/dttyN3L6 The file that processes the form is called upload.php I have never really
We have a web-server designed using select() that never really saw much load until
I am not too new to Java, though I have never really worked with
I have never really done this before so i was hoping that someone could
I have never really done much C but am starting to play around with
G'day, I have never really used excel formulas before but need to convert a
Although I know the basic concepts of binary representation, I have never really written

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.