471,066 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Need help with regex expression

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” <us******@domain.com>

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 27 '08 #1
6 1383
mo******@gmail.com 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” <us******@domain.com>

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
Jun 27 '08 #3
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 <gu...@guffa.comwrote:
mohaa...@gmail.com 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” <usern...@domain.com>
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 27 '08 #4
on 20-6-2008, mo******@gmail.com 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 <gu...@guffa.comwrote:
>mohaa...@gmail.com 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” <usern...@domain.com>
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 27 '08 #5
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" <us******@domain.com>;

I need this to work as well as this.

"firstname lastname" <us******@domain.com>; "firstname lastname"
<us******@domain.com>;

Is this hard to change?

On Jun 20, 2:57*am, Hans Kesting <news.han...@spamgourmet.comwrote:
on 20-6-2008, mohaa...@gmail.com 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 <gu...@guffa.comwrote:
mohaa...@gmail.com 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” <usern...@domain.com>
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 27 '08 #6
mo******@gmail.com 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" <us******@domain.com>;

I need this to work as well as this.

"firstname lastname" <us******@domain.com>; "firstname lastname"
<us******@domain.com>;

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 <news.han...@spamgourmet.comwrote:
>on 20-6-2008, mohaa...@gmail.com 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 <gu...@guffa.comwrote:
mohaa...@gmail.com 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” <usern...@domain.com>
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 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Maurice LING | last post: by
18 posts views Thread by Q. John Chen | last post: by
1 post views Thread by hillcountry74 | last post: by
5 posts views Thread by Chris | last post: by
17 posts views Thread by Mark | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.