The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
It uses the following to check if its in a valid format.
(!preg_match("/^.+\@(\[?) [a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/", $email))
I got this code from a book but it dosn't explain it too well and I can't really work out whats happening using the manual so I was hoping someone on here might be able to break it down and point out what exactly it does.
Thanks
Understand it now :0)
If you type 'introduction guide regular expression' or something similar into google, you'll get what you need.
EDIT - that walk through the example expression was very useful - thanks Garin :)
^.+
The string starts with at least 1 character(s)
\@
and is followed by an AT symbol.
(\[?)
After the AT symbol there may be a [ but no more than 1.
[a-zA-Z0-9\-\.]+
Followed by a word that is at least 1 character in length and contains only a-z,A-Z,0-9, - or a full stop, eg microsoft, 192.168.0, specialreserve.co are a match,
\.
This word must be followed by a full stop.
([a-zA-Z]{2,3} | [0-9]{1,3})
The | is an OR which means theres 2 possible valid matches for what comes after the full stop.
[a-zA-Z]{2,3}
It can be a word that only contains A-Z and a-z and is a minium of 2 characters but a maximum of 3 characters, eg com, net, uk in the case of domains.
[0-9]{1,3}
OR it can match to a word that only contains numbers and is a minimum of 1 character but a maximum of 3. This is for matching against IP addresses.
(\]?)
After the domain name there may be a ] but no more than 1.
$
Finally the end of the string must also be the end of a line, ie theres no more text after it.
Not a very good explanation I know. But its a start, you are really better reading a tutorial on it and breaking it down yourself, by far the best way to start understanding regular expression.
[URL]http://gnosis.cx/publish/programming/regular_expressions.html[/URL] is fairly nice, works as a reference manual too as I just had to look up some symbols I didn't remember. :)
It uses the following to check if its in a valid format.
(!preg_match("/^.+\@(\[?) [a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/", $email))
I got this code from a book but it dosn't explain it too well and I can't really work out whats happening using the manual so I was hoping someone on here might be able to break it down and point out what exactly it does.
Thanks