[TYPO3-english] case-insensitive preg_replace on cyrilic letters

Dmitry Dulepov dmitry at typo3.org
Tue Aug 24 21:40:22 CEST 2010


Lina Wolf wrote:
>  Does anyone know how to make preg_replace with modifier i (for case
> insensitivity) work on cyrilic letters?
> calling preg_replace with this regular expression:
>     /(?!<.*?)(?<=\s|[[:punct:]])Капацитет(?=\s|[[:punct:]])(?![^<>]*?>)/i

I think "[[:punct:]]" is not a valid preg construction. I can be mistaken
but it looks like ereg, not preg.

> Should replace corresponding lowercase word in the following text:
> достатъчен капацитет, за да продължите

I am not sure what lnguage it is :) To me it looks like a random set of
cyrillic letters. Normally I am able to recognize russian, unkranian,
belorussian and serbian.

> If the writing is exactly the same it works fine. If we do the same with
> latin letters it also works.
> Any ideas?

Read about preg modifiers in PHP help. I think you need a unicode one +
UTF-8 encoding.

Dmitry Dulepov
TYPO3 core&security team member
Twitter: http://twitter.com/dmitryd
Read more @ http://dmitry-dulepov.com/

More information about the TYPO3-english mailing list