Forum Moderators: coopster
I visited php.net/eregi but that did not help! It just bombarded me with all this code!
Can someone explain to me how eregi works and what would be suitable experssions for a domain and an email address cos there are so many on the web!
Thanks!
^ matches the beginning of a string
[_.+a-z0-9-]+ matches any at least 1 character long sequence of underscore, period, lower case letters, digits and dash. Square brackets define a set of characters to be matched. A dash that appears between two characters of a character stands for any character between these two characters. If the dash is at the end of a character set, it looses it's special meaning and stands for a just a dash.
@ matches the @ sign
[a-z0-9-]+ matches any at least 1 character long sequence (hence the +) of ... you get it
(\.[a-z0-9-]+)* matches zero or more repitions (hence the *) of a period (period has a special meaning in regular expressions outside of square barackets, so it needs to be escaped by a backslash) followed by any at least 1 character long sequence of ...
\.([a-z]{2,}) matches a period followed by any at least two (hence the {2,}) characters long sequence of lowercase letters
$ matches the end of the string
Note that if you use eregi, the pattern matching is case-insensitive such that [a-z] matches lower case x as well as upper case X.
Free regular expressions for lazy people like me :-)
[edited by: jatar_k at 5:30 pm (utc) on Jan. 9, 2005]
[edit reason] linked it up [/edit]