You are here: Re: string http:// conwert to <a href=''>host</a> « PHP Programming Language « IT news, forums, messages
Re: string http:// conwert to <a href=''>host</a>

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]


Удаленная работа для программистов  •  Как заработать на 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

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