EmailDetect Library - A simple solution to detect emails into strings. |
[eluser]Joel Wallis[/eluser]
Hi CI Masters! I'm here to share a library that i write to find valid emails into string datas. It's a simple (really simple!) library, that you can use to work with various emails at the same time. So... Let's to the code. Code: <?php To use it, is very simple... Code: <?php ![]() Sorry for the weak english, i'm trying my best! uhauhauhuhaa So, sugestions and criticals will be welcome!
[eluser]stensi[/eluser]
That's pretty cool. Definitely useful for finding emails in free text fields where it's in the site owner's interest to obfuscate them in some way (ROT13), to prevent bots from spamming their users! I'll test it out when I get the chance, and then will likely use it for the above mentioned purpose.
[eluser]Jamie Rumbelow[/eluser]
Nice! Pretty useful too. My only concern is that a simple explode() and valid_email() will suffice... the overheads of a library might take it's toll in a production environment.
[eluser]gungbao[/eluser]
i would rather find it more efficient to use a regex for that purpose, regex is made for exactly such tasks (and billions more ![]() simply google for it and you will not need to split+iterate cheers chris
[eluser]Armorfist[/eluser]
Many thanks! Believe it or not, I was doing one myself, and the regex wasn't going very well at all. You just saved me a lot of time!
[eluser]Armorfist[/eluser]
Hello, I just found a regex that does this very simplified: Code: //String Hope it helps!
[eluser]gungbao[/eluser]
ahhhm, you do not need any strtolower, you should use the /i in the preg-regex you should use the php "eregi", thats very much faster than the perl-compatible regex-engine
[eluser]gungbao[/eluser]
would be glad if I could help. well, I am not a regex-guru and without my nice oreilly book, i do have only the basics on mind. but '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}^' has a syntax.error (the final ^) and should better try the modified one '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}' the eregi() should grep out all matched emails in the $regs-array http://www.php.net/manual/de/function.eregi.php have fun with regular expression, they are extremely powerful (e.g. see backtracking features. & more) cheers, chris BTW - you homepage is nicely designed
[eluser]Armorfist[/eluser]
[quote author="gungbao" date="1221190956"]would be glad if I could help. well, I am not a regex-guru and without my nice oreilly book, i do have only the basics on mind. but '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}^' has a syntax.error (the final ^) and should better try the modified one '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}' the eregi() should grep out all matched emails in the $regs-array http://www.php.net/manual/de/function.eregi.php have fun with regular expression, they are extremely powerful (e.g. see backtracking features. & more) [/quote] I'm just starting to learn regex, would it really help to buy a book? You mentioned the O'reilly one, I think I'll give it a try. [quote author="gungbao" date="1221190956"] BTW - you homepage is nicely designed [/quote] Thanks ![]() |
Welcome Guest, Not a member yet? Register Sign In |