Reply to Re: ereg_replace

Your name:

Reply:


Posted by Chung Leong on 11/23/05 04:36

Tomek Toczyski wrote:
> I would like find all occurences of "ABC" which are not followed by "123"
> and replace them with "abc". For example:
> "ABC dd" -> "abc dd"
> "ABC123" -> "ABC123"
> "ABC 123" -> "abc 123"
>
> Give me a recipe, please. I've spent 2 hours googling for it.
>
>
> -tt.

preg_replace_callback() is your friend. Use preg_replace_callback().

Example:

function lowercase_callback($m) {
return strtolower($m[0]);
}

$s = preg_replace_callback('/[A-Z]+(?![A-Z\d])/', 'lowercase_callback',
$s);

[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

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