- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我一直在尝试批量删除 Wordpress 帖子中的垃圾链接,如下所示:
<a style="text-decoration: none" href="/price-of-xenical-at-pharmacy">.</a>
它们位于 post_content 列下的 wp_posts 表中。我试图通过在 href 标记中添加 % 的通配符来做到这一点,因为所有 URL 都不同,但 anchor (句号)和内联样式是相同的。
UPDATE wp_posts
SET post_content = REPLACE (post_content,
'<a style="text-decoration:none" href="%">.</a>',
'.');
后来有人告诉我,SQL 不支持我正在尝试做的事情(或者至少不支持我正在做的事情)。
我正在使用显然支持 REGEXP_REPLACE 的 MariaDB ,所以我正在寻找一些关于我需要什么 SQL 查询和正则表达式来大量删除这些链接但保持所有其他内容不变的指导。
非常感谢任何帮助,目的是删除上述字符串,或替换为空格
示例帖子内容,最后一个链接是我需要删除的类型。 :
<h2>Warranty</h2>
<span style="font-size: small"> </span>
<span style="font-size: small">Lorem ipsum dolor sit amet, non risus bibendum quis morbi, duis elit porttitor semper, ante augue at consectetuer elit lectus est, nascetur neque consequuntur donec turpis. Cursus ullamcorper posuere massa interdum, rhoncus blandit, vitae in etiam justo lectus eu fames. Dolor quam dicta wisi class duis. Eleifend sagittis, scelerisque convallis consectetuer sed non aptent. Velit tristique vulputate proin, ipsum diam aliquam. Nibh sit vitae et m</span>
<a href="https://www.example.com/wp-content/image.jpg"><img class="alignright size-full wp-image-56" title="image" src="https://www.example.com/wp-content/image.jpg" alt="image" width="280" height="280" /></a><a style="text-decoration: none" href="/price-of-xenical-at-pharmacy">.</a>
最佳答案
如果你想删除所有 anchor 标签,但保留标签中的文本,请尝试使用此模式:
<a[^>]*>(.*?)</a>
然后,仅替换为第一个捕获组。除了我们使用 (.*?)
来捕获 anchor 标记之间的内容之外,关于该模式没有太多要说的。 .*?
很重要,它告诉正则表达式引擎在第一个 结束标记处停止。否则,如果我们只使用 (.*)
,它可能会消耗多个 anchor 标记,如果它们存在于您的列中的话。
SELECT
REGEXP_REPLACE('<a style="text-decoration:none" href="[^"]*">BLAH</a>',
'<a[^>]*>(.*?)</a>', '$1');
上面的查询输出BLAH
。
如果你只想去掉所有的 anchor 标签,那么使用这个:
SELECT
REGEXP_REPLACE('<a style="text-decoration:none" href="[^"]*">BLAH</a>',
'<a[^>]*>(.*?)</a>', '');
关于mysql - REGEXP_REPLACE 指南,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55040851/
我想让我的 NSIS 代码更具可读性。 我需要一些关于明智地编写代码部分的指南(比如 C# 中有 #region #endregion)或任何可以使编写 NSIS 代码变得有趣和容易的信息. 请帮帮我
我正在尝试找出Gherkin中所有可用的语法/格式,例如关于多行参数以及我不知道的所有其他内容。 在挖掘Google搜索结果之后,似乎综合指南位于here中: 我以为那很好,并且it链接到一个页面,该
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
当我将 guides 添加到 valueAxesSettings 中时,即使我选择 valueAxesSettings 到 valueAxes 中,它也不起作用。此外,valueAxesSetting
我正在寻找有关如何管理 .NET 程序集的三个不同程序集版本号的指针、建议,甚至是口述。 Product 版本是最简单的,因为这似乎通常由业务决定。然后,文件版本似乎用于部署之间的版本控制,其中实际的
昨晚我脑子里冒出一件事。我想知道为什么我们在项目之间仍然有不同的编码风格。由于风格是个人的东西,我认为最好这样对待它。我们为什么不呢?这有什么技术限制吗? 我举几个例子: // Code sample
我有一个应用程序,用户可以在其中从主 Activity 登录,然后可以使用 ListView 浏览实体的层次结构。因此,Activity 堆栈看起来像这样: A -> B -> B -> B -> .
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
大家好,上个月我开始学习 CSS。我做的第一件事是阅读我能在 www.w3school.com 上找到的所有内容,之后我开始阅读 CSS Mastery 2nd版本。我已经建立了几个自己的网站并取得了
我希望用户能够上传个人资料图片。 关于如何最好地处理这个问题,是否有任何指导方针?例如 - 在哪里保存图像?和要使用的文件夹结构。- 让用户难以浏览每个人的个人资料照片? 谢谢。 最佳答案 如果你自己
我有兴趣了解有关条件重启系统及其工作原理的更多信息。我不知道从哪里开始。我一直在查看源代码,但想知道是否有更高级别的指南可用。 最佳答案 Kent Pitman:条件系统 http://www.nhp
我想将小型、精简且平均的基于 C 的解析器合并到我的 Android 项目中。我过去做过 JNI 编程,但没有在 Android 上进行任何类型的 native (C) 开发。我的计划是将 C lib
免责声明:我试图搜索类似的问题,但是它返回了关于每个 C++ 问题的信息...此外,我将感谢任何可以提出更好标题的人。 C++ 中有两个著名的循环结构:while 和for。 我故意忽略了 do ..
我一直在尝试批量删除 Wordpress 帖子中的垃圾链接,如下所示: . 它们位于 post_content 列下的 wp_posts 表中。我试图通过在 href 标记中添加 % 的通配符来做到这
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 6 年前。 Improve
我们正在讨论为实体类定义方法的最佳方式 - 作为扩展方法或使用分部类。我们讨论的这类方法不会修改实体的状态,它们是纯粹的“辅助”方法,可以查询状态并返回值。 这两种方法的主要好处是保持实体类干净,同时
您将如何在 Flutter 中在实际屏幕上实现引导层。像这样: 最佳答案 这不是微不足道的。以下是必需的组件: 首先,你必须open a transparent full screen dialog
我们需要通过在 C/C++ 中实现特定算法来解决的大多数科学计算问题都需要远低于 double 的精度。例如,1e-6、1e-7 精度涵盖了 ODE 求解器或数值积分的 99% 情况。即使在我们确实需
我正在研究对专有 UI 框架(用于桌面应用程序)的 RTL 支持,我想知道:是否有关于如何更改小部件渲染的指南? 我正在寻找以下内容的列表: 复选框标签位于复选框左侧,右对齐 工具栏按钮从右到左排列
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我是一名优秀的程序员,十分优秀!