|
Posted by Toby Inkster on 10/10/76 11:29
Janwillem Borleffs wrote:
> specjal wrote:
>
>> Warning: Unknown modifier '/'
>>
>> $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.
No -- the slashes are used as *delimiters*. The *modifiers* are any extra
characters that occur after the end delimiter. For example:
/foo/i
will match 'foo' case-insensitively. In this example, the 'i' is a
modifier -- it modifies the behaviour of the regular expression to make it
case-insensitive.
Specjal's warning is caused by the third slash. PHP sees the second slash
as the end delimiter, which makes any trailing characters modifiers.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|