Need help with regex expression

M

mohaaron

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” <[email protected]>

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

Göran Andersson

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” <[email protected]>

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}>$
 
M

mohaaron

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.

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” <[email protected]>
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 -
 
H

Hans Kesting

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

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†<[email protected]>
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 -
 
M

mohaaron

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" <[email protected]>;

I need this to work as well as this.

"firstname lastname" <[email protected]>; "firstname lastname"
<[email protected]>;

Is this hard to change?

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


(e-mail address 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” <[email protected]>
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}>$

- Show quoted text -
 
H

Hans Kesting

(e-mail address 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" <[email protected]>;

I need this to work as well as this.

"firstname lastname" <[email protected]>; "firstname lastname"
<[email protected]>;

Is this hard to change?

Just add an extra optional ';'

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


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


(e-mail address 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†<[email protected]>
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}>$

- Show quoted text -
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top