SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regular expression irregularities

    Hey,

    I am trying to have my own set of tags for use in my content manager yoke, and i was using the examples given by Kevin in that tutorial as my basis.

    This one works

    PHP Code:
    $text 
    eregi_replace("\[p]([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[/p]","<img src=\"http://www.nintendoodle.com/graphics/News/\\1\">",$text); 
    However, and for no reason I can figure out, this one does not

    PHP Code:
    eregi_replace("\[p=([-_./a-zA-Z0-9 !&%#?,'=:~]+)]([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[/p]","<img src=\"http://www.nintendoodle.com/graphics/News/\\1\" alt=\"\\2\">",$text); 
    Any ideas?

    Thanks in advance

  2. #2
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dunno. But I find the phrase "regular expression irregularities" highly humorous!

    Sorry.

  3. #3
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well in the second one you don't have a "$text =" in front of the ereg. or is that just a mistake in your post?

    some other things: instead of using ([-_./a-zA-Z0-9 !&%#?,'=:~]+), i would use (.+?). i think that'll work ok.

    and instead of using eregi use preg_replace('/...stuff.../i', '...replacement...', $text). the preg functions are twice as fast as the ereg ones.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •