04-22-2008, 03:07 PM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
It's a regular expression, and they're greek to even seasoned programmers. You can read more about them here, or check out this cheat sheet to try and learn a little about them.
Basically what a regular expression does is match patterns. Like looking for a string within a string, or a specific order of characters, numbers and symbols within a string. The one you have there is looking for an email address,
Code:
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)
(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";
$inenglish = "^(find anything between a-z, 0-9, or with - or _ in it, at least one or more times)(same as before, but this time it can have a period in it, so it'll match emails like email@mail.com or em.ail@mail.com)*@(that @ sign is taken literally, so it's looking for the @ sign in the middle of the email.. this pattern and the next are just like the first, looking for any combination of a-z, 0-9 with dashes, underscores or periods allowed)(see previous. The star after this means it can match the whole thing as many times as possible)*(this last pattern is only looking for a pattern which includes a-z, and it needs to be between 2 and 6 characters in length, ie, .tv, .com, .shop, etc.)$";
The ^ means it will begin at the start of the string to find the pattern it wants. Anything between ( and ) or [ and ] is a grouping of sort, and then there are modifiers which tell it how often to try and find specific characters or numbers, such as * for 0 or more times, + for one or more times.. I won't go too much more into specifics of breaking it down for now, but check out those two sites, and the cheat sheet in particular after to see if you can break it down yourself. Email regex's, though numerous in their differences, are a good starting point because they're pretty basic patterns to learn the syntax from.
-m
|
|
|
|