articlebot — 2004-07-08T09:01:13-04:00 — #1
This is an article discussion thread for discussing the SitePoint article, "Using Regular Expressions in PHP"
system — 2004-07-08T09:01:13-04:00 — #2
This regular expression has a copule of problems. Firstly, I get a REG_ERANGE error and to fix this the '-' characters within the  have to be escaped with a \. Secondly, three-part domain names fail, such as firstname.lastname@example.org
The following works better for me:
system — 2004-10-03T12:12:30-04:00 — #3
worked fine for me, this is another alright insight to regex, ive been reading various different articles, this is another one that helped
system — 2004-12-14T16:15:13-05:00 — #4
Why do all the incorrect email matching expressions come up when you search for them on google. This is yet another example of how the author didn't completely do their homework to find out the complete matching expression for validating email. Sigh
system — 2005-01-01T02:18:22-05:00 — #5
A good overview of some of the possibilities with regex but as noted by others, many valid e-mail addresses will not be accepted by this regex string.
It doesn't account for allowing an apostrophe in a user's name (which is valid according to the relevant RFCs) and it seems to not allow domain extensions such as .co.uk, .com.au or .info.
system — 2005-01-11T07:58:00-05:00 — #6
and it seems to not allow domain extensions such as .co.uk, .com.au or .info.
Have you checked the code for that? Do you think the author didn't check it? Of course it allows these domain extensions. I did the test and it worked. Just do it again and you will see... >:-(
system — 2005-01-21T10:25:25-05:00 — #7
This was the only place I could find that was able to explain the eregi function to me (php.net did, but didn't teach syntax). I don't believe the point of the tutorial was to give you a email validity checker, but that was rather an example of how you could use the code.
system — 2005-02-03T16:07:40-05:00 — #8
Very Helpful..thanks for taking the time to write this
tim_rogovets — 2005-02-04T10:02:59-05:00 — #9
I need to insert line breaks in the eregi expression, but I can't figure out what should I use there. The \
johnkelly — 2005-05-10T21:09:57-04:00 — #10
I don't understand if the plus sign "+" requires one or more of the previous characters does'nt that mean if a user's email address does not have one of the characters, say a "_" or "-" then it will not validate?
chrisdb — 2005-07-13T07:16:47-04:00 — #11
Nice intro, well written but not exactly definitive. some links to further reading would be nice.
gonik — 2005-07-13T07:41:25-04:00 — #12
JohnKelly, the characters included inside the  are the ALLOWED characters that an email address may contain. It doesn't mean that it must include all these.
The + character indicates that the username block of the address (the part before the @ sign) must have AT LEAST one character from the ones included inside the .
system — 2005-10-08T09:20:35-04:00 — #13
will this ^[a-zA-Z0-9._-]+
do for the user name checking..?
quaint — 2005-10-19T06:43:01-04:00 — #14
It probably won't, because it will just check if something is in the string, even when " characters (for instance) cannot be allowed.
I suggest something like
as this means: at least 4 characters of a-z A-Z and 0-9 and _ - and .
note: please correct me if I got this wrong =P I'm no regex expert!
quaint — 2005-10-19T06:46:01-04:00 — #15
WOW, this is WEIRD!!
Seriously, when you look at your COMMENT BENEATH the article it ONLY states the following:
will this ^+
do for the user name checking..?
Posted by: joby Oct 8th, 2005 @ 9:20 AM EDT
Then when I posted a reply I saw you actually posted the same I did just didn't include the $ at the end...
I'd still say my regex is a **** better than yours (otherwise folks might sign on with usernames like: ab, or __)
By the way, EVEN better is:
as it makes sure the FIRST character of a username is a letter or digit.. but whatever, it's all the same
note: again, correct me if I'm wrong... no expert!
gonik — 2005-10-19T20:17:59-04:00 — #16
Actually Quaint's regex would work better if it was:
If you're gonna use dashes (-) inside braces it must be put in the beggining or in the end, because it works like "From * to *", meaning that it would try to much every character between the ASCII representation of underscore (_) and the ASCII representation of the dot (.)
quaint — 2005-10-20T03:26:23-04:00 — #17
Good explanation! Thank you!
lmasi02 — 2005-12-01T06:00:53-05:00 — #18
Hi this is great i can now create my own regular expresion. I would only reuse already made expression cos i did not understand how they come up with them.
system — 2005-12-06T03:37:37-05:00 — #19
system — 2005-12-14T02:15:12-05:00 — #20
Good article to start with Regular Expressions in PHP
next page →