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” <username@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? | | | | re: Need help with regex expression | | | | re: Need help with regex expression mohaaron@gmail.com wrote: Quote:
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” <username@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 | | | | re: Need help with regex expression
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: Quote:
mohaa...@gmail.com wrote: > Quote:
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.
> Quote:
“firstname lastname” <usern...@domain.com>
> Quote:
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.
> Quote:
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 -
| | | | re: Need help with regex expression
on 20-6-2008, mohaaron@gmail.com supposed : Quote:
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 Quote:
On Jun 19, 4:46Â*am, Göran Andersson <gu...@guffa.comwrote: Quote:
>mohaa...@gmail.com wrote: >> Quote:
>>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.
>> Quote:
>>“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 -
| | | | re: Need help with regex expression
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" <username@domain.com>;
I need this to work as well as this.
"firstname lastname" <username@domain.com>; "firstname lastname"
<username@domain.com>;
Is this hard to change?
On Jun 20, 2:57*am, Hans Kesting <news.han...@spamgourmet.comwrote: Quote:
on 20-6-2008, mohaa...@gmail.com supposed :
> Quote:
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
>
>
> Quote:
On Jun 19, 4:46*am, Göran Andersson <gu...@guffa.comwrote: Quote:
mohaa...@gmail.com wrote:
>Hello all,
> Quote: Quote:
>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.
> Quote: Quote:
>“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?
> Quote: Quote:
I added a bit to a regular expression I had for email verification:
> Quote: Quote:
^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
> Quote: Quote:
--
Göran Andersson
_____http://www.guffa.com-Hide quoted text -
> Quote: Quote:
- Show quoted text -- Hide quoted text -
>
- Show quoted text -
| | | | re: Need help with regex expression mohaaron@gmail.com pretended : Quote:
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" <username@domain.com>;
>
I need this to work as well as this.
>
"firstname lastname" <username@domain.com>; "firstname lastname"
<username@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 Quote:
On Jun 20, 2:57Â*am, Hans Kesting <news.han...@spamgourmet.comwrote: Quote:
>on 20-6-2008, mohaa...@gmail.com supposed :
>> Quote:
>>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
>>
>>
>> Quote:
>>On Jun 19, 4:46Â*am, Göran Andersson <gu...@guffa.comwrote:
>>>mohaa...@gmail.com wrote:
>>>>Hello all,
>> Quote:
>>>>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.
>> Quote:
>>>>“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?
>> Quote:
>>>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 -
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|