473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Regex help for email

Hi

I need a regex code for parsing this string to an email array

"mnp test" <ce**@tum.com>,"test testt"
<ot**@par.com>,se**@tttt.com,te**@twest.com

thanks

Oct 18 '07 #1
14 1496
On Oct 18, 10:59 am, gezerpunta <css...@gmail.comwrote:
Hi

I need a regex code for parsing this string to an email array

"mnp test" <c...@tum.com>,"test testt"
<o...@par.com>,s...@tttt.com,t...@twest.com

thanks
Why do you need a regex? Why not just use explode?

<http://www.php.net/explode>

Oct 18 '07 #2
Greetings, ZeldorBlat.
In reply to Your message dated Thursday, October 18, 2007, 21:10:00,

ZOn Oct 18, 10:59 am, gezerpunta <css...@gmail.comwrote:
>Hi

I need a regex code for parsing this string to an email array

"mnp test" <c...@tum.com>,"test testt"
<o...@par.com>,s...@tttt.com,t...@twest.com

thanks
ZWhy do you need a regex? Why not just use explode?

Z<http://www.php.net/explode>

Please, provide code with explode() to put string
"mnp test" <c...@tum.com>,"test testt" <o...@par.com>,s...@tttt.com,t...@twest.com
into
array('c...@tum.com', 'o...@par.com', 's...@tttt.com', 't...@twest.com');
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Oct 21 '07 #3
Greetings, gezerpunta.
In reply to Your message dated Thursday, October 18, 2007, 18:59:31,

gI need a regex code for parsing this string to an email array

g "mnp test" <ce**@tum.com>,"test testt"
g<ot**@par.com>,se**@tttt.com,te**@twest.com

Something like

<?php

$s = '"mnp test" <ce**@tum.com>,"test testt" <ot**@par.com>, se**@tttt.com,te**@twest.com';

if(preg_match_all('#[\s\,]<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi', $s, $ta))
{
var_export($ta[1]);
}

?>
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Oct 21 '07 #4
Greetings, gezerpunta.
In reply to Your message dated Thursday, October 18, 2007, 18:59:31,

<?php

$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt" <ot**@par.com>, se**@tttt.com,te**@twest.com';

if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi', $s, $ta))
{
var_export($ta[1]);
}

?>
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Oct 21 '07 #5

"AnrDaemon" <an*******@freemail.ruwrote in message
news:19***********************@freemail.ru...
Greetings, gezerpunta.
In reply to Your message dated Thursday, October 18, 2007, 18:59:31,

<?php

$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt" <ot**@par.com>,
se**@tttt.com,te**@twest.com';

if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
$s, $ta))
{
var_export($ta[1]);
}
of course you would. however, notice that whatever your prowess at regex,
you lack understanding of the basic email conventions explained in the
rfc(s). your preg doesn't allow for atomic account names. ;^)

hmmmm...this *does* (and then some).

function isEmail($email)
{
if (!$email){ return false; }
$pattern =
"/^((\"[^\"]*?\")|([^\(\)\<\>\@\,\;\:\\\"\[\]\s\*\/]+))@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$/si";
return preg_match($pattern, $email);
}

the pattern above simply needs to be applied to the entire string, and you
get what you want.
Oct 22 '07 #6
Greetings, Steve.
In reply to Your message dated Monday, October 22, 2007, 20:53:00,
S"AnrDaemon" <an*******@freemail.ruwrote in message
Snews:19***********************@freemail.ru...
>Greetings, gezerpunta.
In reply to Your message dated Thursday, October 18, 2007, 18:59:31,

<?php

$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt" <ot**@par.com>,
se**@tttt.com,te**@twest.com';

if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
$s, $ta))
{
var_export($ta[1]);
}
Sof course you would. however, notice that whatever your prowess at regex,
Syou lack understanding of the basic email conventions explained in the
Srfc(s). your preg doesn't allow for atomic account names. ;^)

Example please?
What You mean "atomic account names"?
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Oct 24 '07 #7

"AnrDaemon" <an*******@freemail.ruwrote in message
news:18***********************@freemail.ru...
Greetings, Steve.
In reply to Your message dated Monday, October 22, 2007, 20:53:00,
S"AnrDaemon" <an*******@freemail.ruwrote in message
Snews:19***********************@freemail.ru...
>>Greetings, gezerpunta.
In reply to Your message dated Thursday, October 18, 2007, 18:59:31,

<?php

$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt"
<ot**@par.com>,
se**@tttt.com,te**@twest.com';

if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
$s, $ta))
{
var_export($ta[1]);
}

Sof course you would. however, notice that whatever your prowess at
regex,
Syou lack understanding of the basic email conventions explained in the
Srfc(s). your preg doesn't allow for atomic account names. ;^)

Example please?
read the freaking email rfc(s).
What You mean "atomic account names"?
hmmmm, what do you think?

the rfc's allow for 'illegal' characters in account names as long as they're
encapsulated. this is to compensate for non-latin character sets
(particularly, non-english sets). is that ringing a bell?

Oct 24 '07 #8
Greetings, Steve.
In reply to Your message dated Wednesday, October 24, 2007, 21:34:41,
>>><?php

$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt"
<ot**@par.com>,
se**@tttt.com,te**@twest.com';

if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
$s, $ta))
{
var_export($ta[1]);
}

Sof course you would. however, notice that whatever your prowess at
regex,
Syou lack understanding of the basic email conventions explained in the
Srfc(s). your preg doesn't allow for atomic account names. ;^)

Example please?
Sread the freaking email rfc(s).

Do it for me, please.
>What You mean "atomic account names"?
Shmmmm, what do you think?

Sthe rfc's allow for 'illegal' characters in account names as long as they're
Sencapsulated. this is to compensate for non-latin character sets
S(particularly, non-english sets). is that ringing a bell?

Never saw any in 10 years. And I think I'll never see.
Not all what allowed by RFC is acceptable by real ISP's.
Typical rules I see around the world:
(?i)^[a-z][0-9a-z]*(?:[\.\-\_][0-9a-z]+)*$
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Oct 24 '07 #9

"AnrDaemon" <an*******@freemail.ruwrote in message
news:90**********************@freemail.ru...
Greetings, Steve.
In reply to Your message dated Wednesday, October 24, 2007, 21:34:41,
>>>><?php
>
$s = 'c***@tum.com, "mnp test" <ce**@tum.com>,"test testt"
<ot**@par.com>,
se**@tttt.com,te**@twest.com';
>
if(preg_match_all('#(?:^|[\s\,])<?([0-9A-Za-z\_]+(?:[\-\.][0-9A-Za-z\_]+)*\@[0-9A-Za-z]+(?:[\.\-\_][0-9A-Za-z]+)+)>?#xi',
$s, $ta))
{
var_export($ta[1]);
}

Sof course you would. however, notice that whatever your prowess at
regex,
Syou lack understanding of the basic email conventions explained in
the
Srfc(s). your preg doesn't allow for atomic account names. ;^)

Example please?

Sread the freaking email rfc(s).

Do it for me, please.
WTF?!!! i read it for me...and those that pay me. you may continue to be
lazy at your liesure.
>>What You mean "atomic account names"?

Shmmmm, what do you think?

Sthe rfc's allow for 'illegal' characters in account names as long as
they're
Sencapsulated. this is to compensate for non-latin character sets
S(particularly, non-english sets). is that ringing a bell?

Never saw any in 10 years.
and you speak english and type with a 'normal' keyboard. now, for the
chinese, japanese, etc. people out there...well, you should get the point.
hell, even this plain english account is valid:

"oops, there's spaces and commas and shit"@example.com

get the picture, cupcake?
And I think I'll never see.
good for you. glad you feel that way. that doesn't change the fact that
email rfc standards define and allow for it.
Not all what allowed by RFC is acceptable by real ISP's.
uhmmmm...'real' isp? hmmmm, what would a 'fake' isp look like i wonder?
maybe like the sprint commercials where 'the other guy's network' is a bunch
of propped up pictures of people. can you hear me now? ROFLMAO!

ok, nimrod...why not quantify and qualify that statement so no one here
thinks you're just talking outta your ass.

which isp does NOT support which rfc standard(s)?

since you haven't even READ ONE SINGLE email rfc, i doubt you can back
yourself up...save, to backpeddle.
Typical rules I see around the world:
(?i)^[a-z][0-9a-z]*(?:[\.\-\_][0-9a-z]+)*$
that's because you're viewing the world through your ass. RTFM.
Sincerely Yours,
i don't want you...unless returning you means i can get a refund!

run along now.
Oct 25 '07 #10
..oO(AnrDaemon)
>Greetings, Steve.
In reply to Your message dated Wednesday, October 24, 2007, 21:34:41,

Sthe rfc's allow for 'illegal' characters in account names as long as they're
Sencapsulated. this is to compensate for non-latin character sets
S(particularly, non-english sets). is that ringing a bell?

Never saw any in 10 years. And I think I'll never see.
Not all what allowed by RFC is acceptable by real ISP's.
It's also not acceptable to improperly mark quoted lines in a reply,
because it makes the postings very hard to read. The Usenet way is a
single '>', so please adjust your newsreader. I think I've already
mentioned that.

Micha
Oct 25 '07 #11

"Michael Fesser" <ne*****@gmx.dewrote in message
news:4q********************************@4ax.com...
.oO(AnrDaemon)
>>Greetings, Steve.
In reply to Your message dated Wednesday, October 24, 2007, 21:34:41,

Sthe rfc's allow for 'illegal' characters in account names as long as
they're
Sencapsulated. this is to compensate for non-latin character sets
S(particularly, non-english sets). is that ringing a bell?

Never saw any in 10 years. And I think I'll never see.
Not all what allowed by RFC is acceptable by real ISP's.

It's also not acceptable to improperly mark quoted lines in a reply,
because it makes the postings very hard to read. The Usenet way is a
single '>', so please adjust your newsreader. I think I've already
mentioned that.
i've been biting my tongue on that one so i could stay on topic with the
regex. thanks for pointing that out.

cheers.
Oct 25 '07 #12
..oO(Steve)
>"Michael Fesser" <ne*****@gmx.dewrote
>>
It's also not acceptable to improperly mark quoted lines in a reply,
because it makes the postings very hard to read. The Usenet way is a
single '>', so please adjust your newsreader. I think I've already
mentioned that.

i've been biting my tongue on that one so i could stay on topic with the
regex. thanks for pointing that out.
I've bitten my tongue too often. ;-)

Micha
Oct 25 '07 #13

"Michael Fesser" <ne*****@gmx.dewrote in message
news:ag********************************@4ax.com...
.oO(Steve)
>>"Michael Fesser" <ne*****@gmx.dewrote
>>>
It's also not acceptable to improperly mark quoted lines in a reply,
because it makes the postings very hard to read. The Usenet way is a
single '>', so please adjust your newsreader. I think I've already
mentioned that.

i've been biting my tongue on that one so i could stay on topic with the
regex. thanks for pointing that out.

I've bitten my tongue too often. ;-)
i actually used to use a non-standard delimiter b/c it made things more
readable in my newsreader. after you quite nicely asked if i'd change it for
the benefit of all, we have the end result.

i think you can give yourself a break on this subject - your tongue anyway.
:)
Oct 25 '07 #14
..oO(Steve)
>"Michael Fesser" <ne*****@gmx.dewrote
>>
I've bitten my tongue too often. ;-)

i actually used to use a non-standard delimiter b/c it made things more
readable in my newsreader. after you quite nicely asked if i'd change it for
the benefit of all, we have the end result.
I can remember.
>i think you can give yourself a break on this subject - your tongue anyway.
;-)

I know about different kinds of delimiters. Some are quite common in
chatrooms and I've also used some of them years ago, but today most
newsreaders are programmed for '>' at the beginning of a line. That's
what makes a quote, like '-- ' makes a signature. It's just a common,
non-written standard, that helps to make Usenet a better place.

But this is _really_ OT here, so EOT.

Micha
Oct 26 '07 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3....
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
16
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at...
5
by: Mark Johnson | last post by:
Regex("@("); brings an error (missing ")"). How do you serarch for a ( with Regex ? Mark Johnson, Berlin Germany mj10777@mj10777.de
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
4
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
9
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
0
by: Support Desk | last post by:
That’s it exactly..thx -----Original Message----- From: Reedick, Andrew Sent: Tuesday, June 03, 2008 9:26 AM To: Support Desk Subject: RE: regex help The regex will now skip anything with...
4
by: seberino | last post by:
I'm looking over the docs for the re module and can't find how to "NOT" an entire regex. For example..... How make regex that means "contains regex#1 but NOT regex#2" ? Chris
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.