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
  • 193,403
  • 52
  • 435
  • 836
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
  • 6,070
  • 12
  • 57
  • 83
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
  • 44,808
  • 15
  • 79
  • 90