Reply to Re: string http:// conwert to <a href=''>host</a>

Your name:

Reply:


Posted by Toby Inkster on 11/22/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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация