0
class autoActiveLink {

    function makeActiveLink($originalString){

        $newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);
        return $newString;
    }

}

What should I replace the function ereg_replace with? I tried preg_replace, but the error still persists.

hakre
  • 184,866
  • 48
  • 414
  • 792
Lalo
  • 11
  • 1
  • 4

2 Answers2

3
preg_replace()

http://php.net/manual/en/function.preg-replace.php

It is not reasonable that the error still exists after you replaced it to preg_replace

But the pattern syntax is different, youll have to convert it

fatnjazzy
  • 5,840
  • 11
  • 54
  • 82
3

Try

class autoActiveLink {
    function makeActiveLink($originalString){
        $newString = preg_replace('#([A-Za-z]+://[^<>\s]+[A-Za-z0-9/])#','<a href="$1" target="_blank">$1</a>', $originalString);
        return $newString;
    }
}
Shef
  • 43,457
  • 15
  • 77
  • 89