Advertisement

05.27.2008 at 10:44AM PDT, ID: 23435690
[x]
Attachment Details

How would I correct this regex to allow for the presence or lack of a space?

Asked by richardsimnett in Java Programming Language

Hello,
I have a bit of regex below, whcih is used to validate input from an email transaction. While I thought it was rfc compliant, some mail servers do not include the space in the command that I require. So I need to know how to alter this regex so that it returns true, regardless of whether the space is there or not.

Here is the code:

public boolean isValidMailFrom(String mailFrom)
    {
        final String RE_EMAIL = "(?i)Mail From: <[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}>";
        return mailFrom.matches(RE_EMAIL);
    }

The space in question is between the : and the <.

A working fix is worth 500 points.

Thanks,
RickStart Free Trial
 
Loading Advertisement...
 
[+][-]05.27.2008 at 10:47AM PDT, ID: 21653968

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.27.2008 at 11:07AM PDT, ID: 21654158

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 11:10AM PDT, ID: 21654190

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628