【问题标题】:MySQL find and replace - add a line breakMySQL 查找和替换 - 添加换行符
【发布时间】:2018-07-30 09:42:36
【问题描述】:

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

比如我要改:

ish.nArchipelago

进入:

ish.
Archipelago

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

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

这对吗?

【问题讨论】:

  • 是每次出现<word>.n<word> 还是只是那个特定的?
  • 谢谢。基本上每个<word>.n<word> 都需要是:<word>. <word>

标签: mysql sql wordpress


【解决方案1】:

替换每一个出现的

<word>.n<word>

<word>.
<word>

使用

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

您的查询将是:

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

【讨论】:

  • 谢谢你。太好了。
  • 我做到了,但我做不到,因为我还没有 15 个声望。系统是这么说的。我一到那里就会添加它。再次感谢您。
猜你喜欢
  • 2017-05-18
  • 2019-10-23
  • 1970-01-01
  • 2013-06-25
  • 2014-09-20
  • 2022-06-15
  • 1970-01-01
  • 2018-01-09
相关资源
最近更新 更多