Answer the question
In order to leave comments, you need to log in
How to separate "stuck together" words in a table?
There is a table prefix_users
The table has a column name
This column contains the names of users of the form:
Коробков Олег Иванович
Горбачевская Юлия Васильевна
Inessa Oliynichenko
Stasenido
Семенова ИринаВикторовна
Иванова ОльгаВикторовна
Семенова ИринаВикторовна
Семенова Ирина Викторовна
Answer the question
In order to leave comments, you need to log in
First check the correctness of the fixes:
SELECT `name`, REGEXP_REPLACE(`name`, '([a-zа-яё])([A-ZА-ЯЁ])', '\\1 \\2', 1, 0, 'c') FROM `prefix_users` WHERE REGEXP_LIKE(`name`, '([a-zа-яё])([A-ZА-ЯЁ])', 'c')
UPDATE `prefix_users` SET `name`=REGEXP_REPLACE(`name`, '([a-zа-яё])([A-ZА-ЯЁ])', '\\1 \\2', 1, 0, 'c') WHERE REGEXP_LIKE(`name`, '([a-zа-яё])([A-ZА-ЯЁ])', 'c')
If only split by case:
<?php
function split_name($name) {
return mb_ereg_replace_callback(
'([а-яa-z])([А-ЯA-Z])',
function($m) {
return $m[1] . ' ' . $m[2];
},
$name
);
}
echo split_name('Семенова ИринаВикторовна') . PHP_EOL;
echo split_name('Иванова ОльгаВикторовна') . PHP_EOL;
echo split_name('InessaIvanovna Oliynichenko') . PHP_EOL;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question