D
D
DumpyCoder2014-01-07 15:13:11
PHP
DumpyCoder, 2014-01-07 15:13:11

How to write a search for Russian capital letters in a string (regexp, php)?

File encoding: UTF-8
Code:

$string = "Test123 Тест";
echo preg_replace('![A-Z|А-Я]!','',$string);

Result:
est123 ст
Question:
Why did the regular season affect the lowercase Russian character "e"?
Regular expression misspelled?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex Pro, 2014-01-07
@DumpyCoder

echo preg_replace('![A-Z|А-Я]!u','-',$string);
www.php.net/manual/ru/reference.pcre.pattern.modif...
Modifier 'u'

E
Edward, 2014-01-07
@gooda

I'm not a regular season specialist myself, but try
preg_replace('/[^a-zа-я\d\s]/', '', $string)

S
Sergey, 2014-01-07
Protko @Fesor

habrahabr.ru/post/45910

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question