Reply to Re: regex negative look behind not working

Your name:

Reply:


Posted by brendan on 09/14/05 13:27

"Chung Leong" <chernyshevsky@hotmail.com> wrote in message
news:1126644521.260826.103720@g44g2000cwa.googlegroups.com...
> That doesn't work, because the pattern will match again as soon as the
> regexp engine looks one letter to the right.

> A job like this is easier with preg_replace_callback(), arguably the
> most powerful text manipulation function in PHP. Example:
>
> function antispam($m) {
> return ($m[1]) ? $m[0] :
> "<script>document.write('<a
>
href=\'mailto:'+'{$m[3]}'+'@'+'{$m[4]}'+'\'>'+'$m[3]'+'@'+'$m[4]'+'</a>');</
script>";
> }
>
>
preg_replace_callback('/(mailto:)?\s*(([_\\.0-9a-z-]+)@([_\\.0-9a-z-]+))/i',
> 'antispam', $string);
>
Excellent, this works perfectly.

[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

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