My problem with separate emails |
[eluser]frrose[/eluser]
Hello every body i have this code to separate emails from srt Code: function get_emails ($str) if there is something like aaa@aaa the code will take it like email ![]() also if there is an email like [email protected] willtake just [email protected] ![]() is there any body can help me ??
[eluser]sophistry[/eluser]
email address regex is very complicated. see this post for some work i did about 6 months ago. http://ellislab.com/forums/viewthread/89516/
[eluser]frrose[/eluser]
I saw your code there and made this change on my code Code: function get_emails ($str) but i also still have a problem if on str i have [email protected]@bbb.bbb the code will take just [email protected] ![]() last part of email must have one . only how to do it ? thanks
[eluser]Mike Ryan[/eluser]
Validating email addresses is more complicate than you might think - see here for a more detailed explanation. The last part of an email address can definitely have more than one dot - e.g. [email protected] is a valid email address. I would split the array based on your chosen delimiter, then test each email address. Let's say your delimiter is the space character: Code: $addresses = explode(' ', $emails );
[eluser]sophistry[/eluser]
@ffrose... that's not my code. my code is much more complex and inscrutable! ;-) also, what exactly is wrong with that behavior you cite anyway? what would you like the email detector to do? it has to make some kind of decision because there is only one @ sign allowed in an email address (assuming you aren't parsing the more free-form section and just dealing with actual addresses). |
Welcome Guest, Not a member yet? Register Sign In |