SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    boiler up blackdog's Avatar
    Join Date
    Jul 2002
    Location
    Purdue
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    '[' causing problems

    i keep getting errors from this line of code:
    PHP Code:
    ereg("[url"$comment
    this is the error: Warning: ereg() [function.ereg]: REG_EBRACK in /home/mobile/public_html/addcomment.php

    however this works:
    PHP Code:
    ereg("http"$comment
    so i'm inclined to think it's the '[' that's causing the problems. any idea how i can fix this?

    thanks!

  2. #2
    SitePoint Member
    Join Date
    Sep 2005
    Location
    Poland
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to add backslash before [

    PHP Code:
    ereg("\[url"$comment
    You can find more information about regular expressions at PHP manual

  3. #3
    SitePoint Evangelist Andrewaclt's Avatar
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must escape the character with a \. [] are generally used to specify ranges in regular expressions, e.g. [0-9] will match all digits zero through nine.

    PHP Code:
    ereg("\[url"$comment
    Last edited by Andrewaclt; Jun 14, 2007 at 05:21. Reason: ahh he beat me to it :)

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Location
    Frankfurt/Germany
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many prefer preg_match as the faster alternative to ereg.

  5. #5
    boiler up blackdog's Avatar
    Join Date
    Jul 2002
    Location
    Purdue
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah that was simple!

    thanks for the advice mainlink, i'll give it a shot.


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
  •