Need help with regex expression

Discussion in 'ASP .Net' started by mohaaron@gmail.com, Jun 18, 2008.

  1. Guest

    Hello all,

    I'm not very good with writing regular expressions and need some help
    with this one. I need to validate an email address which has the full
    name of the person appended to the beginning of it. Here is an example
    of what I’m trying to validate.

    “firstname lastname” <>

    I need to enforce this format so the web form won’t allow submit
    unless it’s like this. So the regex needs to make sure there is a
    word, or two words or more, inside of double quotes, then a space,
    then angle backet, then email, then closing angle bracket.

    Does anyone have a regex expression that can do this or know how to
    write one?
     
    , Jun 18, 2008
    #1
    1. Advertising

  2. Munna Guest

    1. Advertising

  3. wrote:
    > Hello all,
    >
    > I'm not very good with writing regular expressions and need some help
    > with this one. I need to validate an email address which has the full
    > name of the person appended to the beginning of it. Here is an example
    > of what I’m trying to validate.
    >
    > “firstname lastname” <>
    >
    > I need to enforce this format so the web form won’t allow submit
    > unless it’s like this. So the regex needs to make sure there is a
    > word, or two words or more, inside of double quotes, then a space,
    > then angle backet, then email, then closing angle bracket.
    >
    > Does anyone have a regex expression that can do this or know how to
    > write one?


    I added a bit to a regular expression I had for email verification:

    ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    Göran Andersson, Jun 19, 2008
    #3
  4. Guest

    Ah, yes. In my haste to write this post I forgot to say that I need
    this to validate multiple emails seperated by a semi-colon. I think
    this throws a wrench into the problem doesn't it.

    On Jun 19, 4:46 am, Göran Andersson <> wrote:
    > wrote:
    > > Hello all,

    >
    > > I'm not very good with writing regular expressions and need some help
    > > with this one. I need to validate an email address which has the full
    > > name of the person appended to the beginning of it. Here is an example
    > > of what I’m trying to validate.

    >
    > > “firstname lastname” <>

    >
    > > I need to enforce this format so the web form won’t allow submit
    > > unless it’s like this. So the regex needs to make sure there is a
    > > word, or two words or more, inside of double quotes, then a space,
    > > then angle backet, then email, then closing angle bracket.

    >
    > > Does anyone have a regex expression that can do this or know how to
    > > write one?

    >
    > I added a bit to a regular expression I had for email verification:
    >
    > ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
    >
    > --
    > Göran Andersson
    > _____http://www.guffa.com- Hide quoted text -
    >
    > - Show quoted text -
     
    , Jun 20, 2008
    #4
  5. Hans Kesting Guest

    on 20-6-2008, supposed :
    > Ah, yes. In my haste to write this post I forgot to say that I need
    > this to validate multiple emails seperated by a semi-colon. I think
    > this throws a wrench into the problem doesn't it.
    >


    Not *that* much:

    ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
    <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$

    original test,
    followed by zero or more occurences of
    optional whitespace, a ';', more optional whitespace and
    the original test again.

    But maybe the {2,4} multiplier should be adjusted somewhat to at least
    {2,6}, as there are now top-level domains of .museum and .travel!

    Hans Kesting


    > On Jun 19, 4:46 am, Göran Andersson <> wrote:
    >> wrote:
    >>> Hello all,

    >>
    >>> I'm not very good with writing regular expressions and need some help
    >>> with this one. I need to validate an email address which has the full
    >>> name of the person appended to the beginning of it. Here is an example
    >>> of what I’m trying to validate.

    >>
    >>> “firstname lastname†<>
    >>> I need to enforce this format so the web form won’t allow submit
    >>> unless it’s like this. So the regex needs to make sure there is a
    >>> word, or two words or more, inside of double quotes, then a space,
    >>> then angle backet, then email, then closing angle bracket.
    >>> Does anyone have a regex expression that can do this or know how to
    >>> write one?

    >>
    >> I added a bit to a regular expression I had for email verification:
    >>
    >> ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
    >>
    >> --
    >> Göran Andersson
    >> _____http://www.guffa.com- Hide quoted text -
    >>
    >> - Show quoted text -
     
    Hans Kesting, Jun 20, 2008
    #5
  6. Guest

    Hello Hans,

    Thank you so much for getting me this. I'm having a problem with it
    though. When I enter the semi-colon at the end to all a second name +
    email to be entered it doesn't validate anymore.

    The following doesn't work.

    "firstname lastname" <>;

    I need this to work as well as this.

    "firstname lastname" <>; "firstname lastname"
    <>;

    Is this hard to change?

    On Jun 20, 2:57 am, Hans Kesting <> wrote:
    > on 20-6-2008, supposed :
    >
    > > Ah, yes. In my haste to write this post I forgot to say that I need
    > > this to validate multiple emails seperated by a semi-colon. I think
    > > this throws a wrench into the problem doesn't it.

    >
    > Not *that* much:
    >
    > ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
    > <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$
    >
    > original test,
    > followed by zero or more occurences of
    >    optional whitespace, a ';', more optional whitespace and
    >    the original test again.
    >
    > But maybe the {2,4} multiplier should be adjusted somewhat to at least
    > {2,6}, as there are now top-level domains of .museum and .travel!
    >
    > Hans Kesting
    >
    >
    >
    > > On Jun 19, 4:46 am, Göran Andersson <> wrote:
    > >> wrote:
    > >>> Hello all,

    >
    > >>> I'm not very good with writing regular expressions and need some help
    > >>> with this one. I need to validate an email address which has the full
    > >>> name of the person appended to the beginning of it. Here is an example
    > >>> of what I’m trying to validate.

    >
    > >>> “firstname lastname” <>
    > >>> I need to enforce this format so the web form won’t allow submit
    > >>> unless it’s like this. So the regex needs to make sure there is a
    > >>> word, or two words or more, inside of double quotes, then a space,
    > >>> then angle backet, then email, then closing angle bracket.
    > >>> Does anyone have a regex expression that can do this or know how to
    > >>> write one?

    >
    > >> I added a bit to a regular expression I had for email verification:

    >
    > >> ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$

    >
    > >> --
    > >> Göran Andersson
    > >> _____http://www.guffa.com-Hide quoted text -

    >
    > >> - Show quoted text -- Hide quoted text -

    >
    > - Show quoted text -
     
    , Jun 24, 2008
    #6
  7. Hans Kesting Guest

    pretended :
    > Hello Hans,
    >
    > Thank you so much for getting me this. I'm having a problem with it
    > though. When I enter the semi-colon at the end to all a second name +
    > email to be entered it doesn't validate anymore.
    >
    > The following doesn't work.
    >
    > "firstname lastname" <>;
    >
    > I need this to work as well as this.
    >
    > "firstname lastname" <>; "firstname lastname"
    > <>;
    >
    > Is this hard to change?
    >


    Just add an extra optional ';'

    ^"[^"]+"
    <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*;?$


    Hans Kesting

    > On Jun 20, 2:57 am, Hans Kesting <> wrote:
    >> on 20-6-2008, supposed :
    >>
    >>> Ah, yes. In my haste to write this post I forgot to say that I need
    >>> this to validate multiple emails seperated by a semi-colon. I think
    >>> this throws a wrench into the problem doesn't it.

    >>
    >> Not *that* much:
    >>
    >> ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
    >> <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$
    >>
    >> original test,
    >> followed by zero or more occurences of
    >>    optional whitespace, a ';', more optional whitespace and
    >>    the original test again.
    >>
    >> But maybe the {2,4} multiplier should be adjusted somewhat to at least
    >> {2,6}, as there are now top-level domains of .museum and .travel!
    >>
    >> Hans Kesting
    >>
    >>
    >>
    >>> On Jun 19, 4:46 am, Göran Andersson <> wrote:
    >>>> wrote:
    >>>>> Hello all,

    >>
    >>>>> I'm not very good with writing regular expressions and need some help
    >>>>> with this one. I need to validate an email address which has the full
    >>>>> name of the person appended to the beginning of it. Here is an example
    >>>>> of what I’m trying to validate.

    >>
    >>>>> “firstname lastname†<>
    >>>>> I need to enforce this format so the web form won’t allow submit
    >>>>> unless it’s like this. So the regex needs to make sure there is a
    >>>>> word, or two words or more, inside of double quotes, then a space,
    >>>>> then angle backet, then email, then closing angle bracket.
    >>>>> Does anyone have a regex expression that can do this or know how to
    >>>>> write one?

    >>
    >>>> I added a bit to a regular expression I had for email verification:
    >>>> ^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
    >>>> --
    >>>> Göran Andersson
    >>>> _____http://www.guffa.com-Hide quoted text -
    >>>> - Show quoted text -- Hide quoted text -

    >>
    >> - Show quoted text -
     
    Hans Kesting, Jun 25, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr
    Replies:
    3
    Views:
    808
    bloomfield
    Jun 21, 2004
  2. msnews.microsoft.com

    Help for RegEx Expression

    msnews.microsoft.com, Mar 1, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    332
    msnews.microsoft.com
    Mar 1, 2005
  3. msnews.microsoft.com

    Help for Regex Expression

    msnews.microsoft.com, Mar 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    341
    jongalloway
    Mar 6, 2005
  4. Replies:
    3
    Views:
    833
    Reedick, Andrew
    Jul 1, 2008
  5. Sherm Pendley

    need to negate regex in middle of expression

    Sherm Pendley, Jun 20, 2005, in forum: Perl Misc
    Replies:
    8
    Views:
    170
    Tad McClellan
    Jun 20, 2005
Loading...

Share This Page