Help With Preg_replace And Ereg_replace

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help With Preg_replace And Ereg_replace

    $AOG_te = ereg_replace("http://[A-Za-z0-9./=?-_]+","<a href="\\0">\\0</a>", $AOG_te);
    $AOG_te = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href="$1">$2</a>",$AOG_te);
    i have that above code in my bbcode function.
    But ereg_replace did not allow the preg_replace to work, what can i do so that two will work without affecting each other.
    If user post http:// coding-talk.com or [ url=http:// coding-talk.com]coding-talk[/url] should turn to link.
    have connected with http://adexchat.com ?
    Fun up with
    http://forum.adexchat.com

    #2
    the problem arises when using double quotes. Try using single quotes.

    [NOTE]: function ereg_replace() is deprecated as of PHP 5.3.0.

    PHP Code:
    $AOG_te ereg_replace('http://[A-Za-z0-9./=?-_]+','<a href="$1">$2</a>',$AOG_te);
    $AOG_te preg_replace('/\[url\=(.*?)\](.*?)\[\/url\]/is','<a href="$1">$2</a>',$AOG_te); 
    Last edited by Freddynic159; 27.08.14, 20:57.

    Comment


      #3
      not working, it return [url=$2
      have connected with http://adexchat.com ?
      Fun up with
      http://forum.adexchat.com

      Comment


        #4
        Try this:
        PHP Code:
        $URLSearchString " a-zA-Z0-9\:\&\/\-\?\.\=\_\~\#\'";  
        $AOG_te preg_replace("(\[url\]([$URLSearchString]*)\[/url\])is"'<a href="$1">$1</a>'$AOG_te);
        $AOG_te preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])is"'<a href="$1" >$2</a>'$AOG_te); 

        Comment

        Working...
        X