|
Posted by Janwillem Borleffs on 11/27/32 11:29
specjal wrote:
> Warning: Unknown modifier '/'
> what is wrong?
>
> $tresc = preg_replace('/(http)(s?)(://)([^ ]+)/', '<a
> href="$1$2$3$4">$1$2$3$4</a>', tresc);
>
The slashes are used as modifiers to mark the beginning and the end of the
pattern, but they are also used in the pattern itself.
You can fix this by escaping the slashes in the pattern:
$tresc = preg_replace('/(http)(s?)(:\/\/)([^ ]+)/', '<a
href="$1$2$3$4">$1$2$3$4</a>', tresc);
Or by using another modifier:
$tresc = preg_replace('#(http)(s?)(://)([^ ]+)#', '<a
href="$1$2$3$4">$1$2$3$4</a>', tresc);
JW
Navigation:
[Reply to this message]
|