MySQL查找和替换-添加换行符

时间:2018-07-30 09:42:36

标签: mysql sql wordpress

从另一个系统迁移网站后,我有一些文本需要在单词之间换行。

例如,我要更改:

ish.nArchipelago

进入:

ish.
Archipelago

我当前正在使用以下查询:

UPDATE wp_posts 
SET post_content = REPLACE(post_content, 'ish.nArchipelago', 'ish.\nArchipelago');

这正确吗?

1 个答案:

答案 0 :(得分:0)

替换每次出现的

<word>.n<word>

使用

<word>.
<word>

使用

REGEXP_REPLACE(string, '\.n', '\.\n');

您的查询将是:

UPDATE wp_posts 
SET post_content = REGEXP_REPLACE(post_content, '\.n', '\.\n');