Posted by Petr Vileta on 01/04/07 01:23
"monomaniac21" <mcyi2mr3@googlemail.com> píse v diskusním príspevku
news:1167838622.294198.287760@n51g2000cwc.googlegroups.com...
> 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
>
preg_replace('/^([^i]+)i*$/i','$1',$string);
320i will be 320
320ii will be 320
preg_replace('/^(.+)i*$/i','$1',$string);
320i will be 320
320ii will be 320i
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
[Back to original message]
|