![]() ![]() |
6 Mar 2010, 07:47 AM
Post
#1
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1282 Joined: 9-July 02 Member No.: 5061 |
hello enyone,
has anybody ever check an email string if it is right like it must have an @ in this string? if yes, how you solve it? I know it must be with strregex thanks gr phoenix |
|
|
|
6 Mar 2010, 08:51 AM
Post
#2
|
|
|
Town Joker ![]() ![]() ![]() Group: Members Posts: 95 Joined: 1-February 07 Member No.: 38366 |
a regex string to totally check emails is like a bottomless bottle... it always can be improved to include some other characters, it never is gonna be perfect.. xD
anyway, lasttime i tried, it was in PHP (as thats what i am doing) and i used this lines: CODE $len = strlen($email);
if($len < 5 || $len > 50 || !preg_match("/[\.a-z0-9_-]+@[a-z0-9-.]{2,}\.[a-z]{2,4}$/i",$email)) $err[] = "register_email_invalid"; |
|
|
|
6 Mar 2010, 10:17 AM
Post
#3
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1282 Joined: 9-July 02 Member No.: 5061 |
how to check in php is no problem.
in the guild system is a similary check for special character with regex. itīs like in php so I tried your code in the sphere language but without success. so it must be... maybe sugarcube knows the answer?!? gr phoenix |
|
|
|
6 Mar 2010, 10:28 AM
Post
#4
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1788 Joined: 5-February 05 From: Argentina Member No.: 29240 |
STRREGEX uses regular expressions. Like you would do with STRMATCH but using regular expresions.
Amadox just gave you the pattern he uses in PHP, it may work in Sphere too. |
|
|
|
6 Mar 2010, 11:23 AM
Post
#5
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1063 Joined: 18-March 05 From: Brazil Member No.: 29955 |
You can use STRMATCH("*@*.*","<ARGS>"), or STRREGEX
|
|
|
|
6 Mar 2010, 08:55 PM
Post
#6
|
|
|
Town Joker ![]() ![]() ![]() Group: Members Posts: 95 Joined: 1-February 07 Member No.: 38366 |
as far as i can see, the sphere thingy doesn't use those / at the beginning and the end, and after taking a closer look at that stuff i posted, i am not sure if that really worked exactly that way.
try those: CODE STRREGEX("^[\.a-zA-Z0-9_-]+@[a-zA-Z0-9-\.]{2,}\.[a-zA-Z]{2,4}$","<args>") CODE STRREGEX("^[\.a-zA-Z0-9_-]+@[a-zA-Z0-9-\.]+[a-zA-Z]+$","<args>") CODE STRREGEX("^[\.a-zA-Z0-9_-]+@[a-zA-Z0-9-\.]+$","<args>") first one should be the best (most correct) choice, if it works. anyway, i'm curious: may i ask what you are doing, that needs email validation ingame? you may answer via pm in german if you like (IMG:style_emoticons/default/wink.gif) |
|
|
|
7 Mar 2010, 09:32 AM
Post
#7
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1282 Joined: 9-July 02 Member No.: 5061 |
|
|
|
|
15 Mar 2010, 11:58 AM
Post
#8
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 737 Joined: 30-December 03 From: Timmins, Ont, Canada Member No.: 15184 |
This is the code I have always used to validate E-mails.
[FUNCTION INVALID.email] IF (STRMATCH(*[^a-z0-9_.-@]*,<ARGS>)) RETURN 1 ELSEIF (!STRMATCH(*?@?*.?*,<ARGS>)) RETURN 1 ELSE RETURN 0 ENDIF |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 1st August 2010 - 03:31 AM |