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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:34:00+00:00 2026-05-27T03:34:00+00:00

Im just trying to validate an email ending with a particular string. Im using

  • 0

Im just trying to validate an email ending with a particular string. Im using PCRE for this…but cant seem to get it to work. The email needs to end in either boisestate.edu or u.boisestate.edu. I’ve been stabbing at this one for awhile…some help would be really appreciated!

This is what I have so far:

if (preg_match("/[a-zA-Z]+[a-z0-9A-Z_-]+@[\.u]?\.boisestate\.edu$/", "melissa@boisestate.edu", $matches)){
echo "Match was found <br />";
print_r($matches);
}
  • 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-27T03:34:01+00:00Added an answer on May 27, 2026 at 3:34 am

    Instead of trying to do the whole email match and domain check in one, you could just filter_var and a much simpler regex for domain validation.

    Example:

    function check_email($address) {
        if (filter_var($address, FILTER_VALIDATE_EMAIL)
                && preg_match('/@(u\.)?boisestate\.edu$/', $address)) {
            print "We have a match!\n";
        } else {
            print "Match failed!\n";
        }
    }
    

    When called like this:

    check_email('garbage');
    check_email('foo@example.com');
    check_email('me@u.boisestate.edu');
    check_email('you@boisestate.edu');
    

    You’ll get the output:

    Match failed!
    Match failed!
    We have a match!
    We have a match!
    

    As far as the regex is concerned, the reason why yours is failing, is because you’re searching for one of the chars in the square-brackets, only once.

    So, you would match things like foo@.boisestate.edu and foo@uboisestate.edu. If you use parenthesis instead of square brackets, the ? will optionally match the entire contents inside the parens.

    @(u\.)?boisestate\.edu$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to get my head around Generics by reading this enlightening article by
Just trying to get diff to work better for certain kinds of documents. With
just trying to test for equality in this piece of code, but getting a
I'm trying to validate a form using Data Annotation. It seems great for string
I'm trying to validate my JSON API using node.js + json-schema.js from commonjs-utils. Just
I'm trying to validate user input, which is just comma separated numbers. I'd like
Just trying to get my irb sessions to actually list the current line of
Just trying to get up to speed with the SDK... So, I've created my
Just trying to get my head round Spring and figuring out how I wire
Just trying to still get my head around IOC principles. Q1: Static Methods -

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.