SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    regular expressions

    I think I got this from Kevin's book and chaged it a little to my needs:

    PHP Code:
    $text ereg_replace("\[L=([-_./a-zA-Z0-9!&%#?,'=:~]+)]"."([-_./a-zA-Z0-9 !&%#?;<>,'=:~]+)\[EL]""<a href=\"\\1\" target=\"_blank\">\\2</a>"$text); 
    It now works also with links that have <br> included. Unfortunately it does not work with links like that:

    "report.php?new_id=2&view=1"

    Why? I think it should work, what did I miss?

    Michael

  2. #2
    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)
    i don't know. those ereg functions with all those characters are a mess. but i can give you the better, faster preg equivalent that should work for you.

    PHP Code:
    $text preg_replace('/\\[L=(.+?)](.+?)\\[EL]/is''<a href="$1" target="_blank">$2</a>'$text); 
    that is case-insensitive, too, unlike yours (e.g. [L=... and l=... work, etc.). if you want it like yours, remove the "i" at the end of the pattern (...[EL]/is).
    - 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

  3. #3
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works great! Thanks!


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
  •