Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Need help with regex expression

Reply
Thread Tools

Need help with regex expression

 
 
mohaaron@gmail.com
Guest
Posts: n/a
 
      06-18-2008
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” <(E-Mail Removed)>

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?
 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
 
Reply With Quote
 
 
 
 
Göran Andersson
Guest
Posts: n/a
 
      06-19-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) 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” <(E-Mail Removed)>
>
> 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
 
Reply With Quote
 
mohaaron@gmail.com
Guest
Posts: n/a
 
      06-19-2008
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 <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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” <(E-Mail Removed)>

>
> > 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 -


 
Reply With Quote
 
Hans Kesting
Guest
Posts: n/a
 
      06-20-2008
on 20-6-2008, (E-Mail Removed) 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 <(E-Mail Removed)> wrote:
>> (E-Mail Removed) 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” <(E-Mail Removed)>
>>> 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 -



 
Reply With Quote
 
mohaaron@gmail.com
Guest
Posts: n/a
 
      06-24-2008
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" <(E-Mail Removed)>;

I need this to work as well as this.

"firstname lastname" <(E-Mail Removed)>; "firstname lastname"
<(E-Mail Removed)>;

Is this hard to change?

On Jun 20, 2:57*am, Hans Kesting <(E-Mail Removed)> wrote:
> on 20-6-2008, (E-Mail Removed) 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 <(E-Mail Removed)> wrote:
> >> (E-Mail Removed) 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” <(E-Mail Removed)>
> >>> 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 -


 
Reply With Quote
 
Hans Kesting
Guest
Posts: n/a
 
      06-25-2008
(E-Mail Removed) 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" <(E-Mail Removed)>;
>
> I need this to work as well as this.
>
> "firstname lastname" <(E-Mail Removed)>; "firstname lastname"
> <(E-Mail Removed)>;
>
> 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 <(E-Mail Removed)> wrote:
>> on 20-6-2008, (E-Mail Removed) 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 <(E-Mail Removed)> wrote:
>>>> (E-Mail Removed) 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” <(E-Mail Removed)>
>>>>> 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 -



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
need to negate regex in middle of expression Sherm Pendley Perl Misc 8 06-20-2005 04:43 PM
help - regex validator expression not weeding out commas Mad Scientist Jr ASP .Net 3 06-21-2004 07:37 AM



Advertisments