Reply to Re: regular expression problem (preg_replace)

Your name:

Reply:


Posted by Rik on 01/03/07 15:50

monomaniac21 wrote:
> hi all
>
> using preg_replace
>
> how can i replace the letter i in a string with nothing (delete it)
> when it is the last letter or it is followed by an i?
>
> i have products that are listed in a db with i or ii as in 320ii and i
> want to strip out the i's at the end when displaying the product name

With last latter, do you mean last letter in a word or the real last
character.
Word:
preg_replace('/i(\b|i)/i','$1',$string);
Dead last:
preg_replace('/i($|i)/si','$1',$string);

If you want to strip out ALL ending i's:
preg_replace('/i+(\b)/i','$1',$string);
--
Rik Wasmus

[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

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