utf 8 - PHP: case-insensitive preg_replace of a cyrillic string in UTF8 -


I have displayed users of my web site and want to change a certain Russian city (PostgreSQL 8.4.7 in UTF Database stored in 8+ CentOS 5.5 / 64 bits Linux) by its old name (this is an insider fun):

  preg_replace ('/ d ?? оР»Ð³Ð¾Ð³Ñ ?? Ð ° d '/ IU', 'Ð¡Ñ ?? Ð ° Ð »Ð¸Ð½Ð³Ñ ?? Ð ° Ð' ', $ city);   

Unfortunately this only works for exact matches: Ð ?? оР»Ð³Ð¾Ð³ÑÑ ?? Ð ° Ð '.

This does not work for other cases, such as Ð ?? Ð ?? Ð ?? Ð ?? Ð ?? Ð ?? D with d ?? Ð ?? or воР»Ð³Ð¾Ð³ÑÑ ?? Ð ° d '.

If I modify my source code

  preg_replace ('/ [d ?? ²²] оР»Ð³Ð¾Ð³Ñ ?? Ð ° d' / IU ',' ¡¡ Ñ ​​?? Ð ° Ð »Ð¸Ð½Ð³Ñ ?? Ð ° Ð ', $ city);   

Then this second matter will be caught above.

Does anyone know what it is going on and how it can be fixed (assuming I do not want to write for every letter [Xx ] )?

Thank you! Alex

Update:

  # rpm -qa | Grep php php53-bcmath-5.3.3-1.el5 php53-gd-5.3 .3-1.el5 php53-common-5.3.3-1.el5 php53-pdo-5.3.3-1.el5 php53-mbstring- 5.3.3-1.el5 php53-xml-5.3.3-1.el5 Php53-5.3.3-1.el5 php53-cli-5.3.3-1.el5 php53-pgsql-5.3.3-1.el5 # Rpm -qa | Grep pcre pcre-6.6-2.el5_1.7  PHP 5.3.3-PHP).   

):
 < Code> $ str1 = 'Ð ?? оР»Ð³Ð¾Ð³ÑÑ ?? Ð ° Ð '; $ Str2 = 'Ð ?? Ð ?? Ð ?? Ð ?? Ð ?? Ð ?? Ð Ð ?? Ð ?? ';;; $ Str3 = 'воÐ' гогÑÑ ?? Ð degree Ð ''; Var_dump (preg_replace ('/ Ð ?? оР»Ð³Ð¾Ð³Ñ ?? Ð ° Ð' / iu ',' Ð¡Ñ ?? Ð ° л Ð¸Ð½Ð³Ñ ?? Ð ° Ð ', $ str1)); Var_dump (preg_replace ('/ d ?? оР»Ð³Ð¾Ð³Ñ ?? Ð ° d' / IU ',' Ð¡Ñ ?? Ð ° л Ð¸Ð½Ð³Ñ ?? Ð ° d '', $ str2)); Var_dump (preg_replace ('/ d ?? оР»Ð³Ð¾Ð³Ñ ?? Ð ° d' / IU ',' С¾ ?? Ð ° л Ð¸Ð½Ð³Ñ ?? Ð ° d '', $ str3));   

output

  string (20) "Ð¡Ñ ?? Ð ° л Ð¸Ð½Ð³Ñ ?? Ð ° Ð '"string (20) "Ð¡Ñ ?? Ð ° л Ð¸Ð½Ð³Ñ ?? Ð ° d '"string (20)" Ð¡Ñ ?? Ð ° Ð »Ð¸Ð½Ð³Ñ ?? Ð ° d'"   

Which PCEE version is using your PHP? Check for phpinfo () for pcre -section This is on my system:

  ... peer PCR (Perl consistent regular expressions ) Help = & gt; Enabled PCRE Library Version = & gt; 8.02 2010-03-19 ...    

Comments