SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 48
  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "Using Regular Expressions in PHP"

  2. #2
    Lindsay
    SitePoint Community Guest
    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 info@john.doe.name
    The following works better for me:
    ^[a-z0-9._\-]+@[a-z0-9\-_]+(\.[a-z0-9\-_]+)*(\.[a-z]{2,5})

  3. #3
    chis
    SitePoint Community Guest
    worked fine for me, this is another alright insight to regex, ive been reading various different articles, this is another one that helped :)

  4. #4
    Suso Banderas
    SitePoint Community Guest
    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

  5. #5
    Richard
    SitePoint Community Guest
    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.

  6. #6
    Andre M.
    SitePoint Community Guest
    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... >:-(

  7. #7
    Brendan
    SitePoint Community Guest
    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.

  8. #8
    rm
    SitePoint Community Guest
    Very Helpful..thanks for taking the time to write this

  9. #9
    SitePoint Addict Tim_Rogovets's Avatar
    Join Date
    Aug 2003
    Location
    Odessa, Ukraine
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resolved: Line breaks in regexp

    I need to insert line breaks in the eregi expression, but I can't figure out what should I use there. The \n doesn't work..
    Last edited by Tim_Rogovets; Feb 4, 2005 at 09:11. Reason: Just found out that I had to use [\n\r] instead of \n
    CEO of Grandiz! - a team based in Odessa, Ukraine.
    Designing and developing sophisticated web apps on CodeIgniter!

  10. #10
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Mountain View, CA
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  11. #11
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice intro, well written but not exactly definitive. some links to further reading would be nice.

  12. #12
    SitePoint Enthusiast Gonik's Avatar
    Join Date
    May 2005
    Location
    Thessaloniki, Greece
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 [].

  13. #13
    joby
    SitePoint Community Guest
    will this ^[a-zA-Z0-9._-]+
    do for the user name checking..?

  14. #14
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @joby

    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
    ^[a-zA-Z0-9_-.]{4,}$

    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!

  15. #15
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW, this is WEIRD!!

    Seriously, when you look at your COMMENT BENEATH the article it ONLY states the following:

    Comment

    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 :P 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:
    ^[a-zA-Z0-9]{1}[a-zA-Z0-9_-.]{3,}$

    as it makes sure the FIRST character of a username is a letter or digit.. but whatever, it's all the same :P

    note: again, correct me if I'm wrong... no expert!

    Quaint Tech
    - Blog on web development and web technology.

  16. #16
    SitePoint Enthusiast Gonik's Avatar
    Join Date
    May 2005
    Location
    Thessaloniki, Greece
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually Quaint's regex would work better if it was:
    Code:
    ^[-a-zA-Z0-9_.]{4,}$
    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 (.)
    Don't Drink & Surf The Net

  17. #17
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good explanation! Thank you!

    Quaint Tech
    - Blog on web development and web technology.

  18. #18
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Thanx again

  19. #19
    webinsight
    SitePoint Community Guest
    Good article, thanks.

  20. #20
    Ravi Shakya
    SitePoint Community Guest
    Good article to start with Regular Expressions in PHP

  21. #21
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Hoffman Estates, IL
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fantastic. Teaches the basics of regular expressions without going over the top for the beginning user.

  22. #22
    Mark Rainbird
    SitePoint Community Guest
    Good article but would not work for UK email addresses as our TLD is reserved and most of our email addresses are name@domain.co.uk which would fail your validation.

  23. #23
    sourabh
    SitePoint Community Guest
    nice article!!1

  24. #24
    kingkong
    SitePoint Community Guest
    very great article, once i read, i have understood about using regular expression in php, keep the good job!

  25. #25
    Mudassar
    SitePoint Community Guest
    HI,
    Great Job man

    But again wht about the

    name@domain.tld1.tld2

    type of mail addresses

    But this was realy simple and make me able to use regular expression who was afraid of their ugly look .............

    Thanks
    TC


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •