【问题标题】:MySql, Wordpress, REPLACE part of post_content text using LIKE (REGEX) operator..MySql,Wordpress,使用 LIKE (REGEX) 运算符替换 post_content 文本的一部分..
【发布时间】:2012-02-16 10:35:14
【问题描述】:

wordpress 中的帖子在 post_content 中有不需要的链接,例如

http://www.thisisbaddomain.com/?x=blahblah (or similar to first blank)

http://thisisbaddomain.com/?x=blahblah www.thisisbaddomain.com/?x=blahblah

我注意到解决方案...php 代码将替换从开始到第一个空白的所有链接(如果链接在该行上单独存在,则删除整行)..

我进行了测试但没有成功:

UPDATE wp_posts SET post_content = REPLACE (post_content, regex '^(http://www.xxx.com)', '');

我知道这个例子不起作用,我知道正则表达式不像 sql 中的 LIKE 那样工作..我被卡住了......我知道以前有人遇到过这样的问题..所以请给我一些工作我会改变它以适合我..

【问题讨论】:

    标签: mysql regex select sql-like


    【解决方案1】:
    【解决方案2】:

    在 MySQL 8 中,您可以使用 REGEXP_REPLACE

    UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '^(http://www.example.com)', '')
    

    【讨论】:

      猜你喜欢
      • 2015-04-17
      • 2022-06-25
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      相关资源
      最近更新 更多