简体   繁体   English

使用MySQL Regex查找和替换

[英]Find and Replace using MySQL Regex

I have a mysql table with column CONTENT . 我有一个带有CONTENT列的mysql表。 CONTENT has some text with the following pattern: CONTENT的文本具有以下模式:

<p class="notice">...</p>

I would like to change this pattern with 我想改变这种模式

<div class="alert">...</div>

How can I use MySQL regex to achieve this replacement? 如何使用MySQL正则表达式来实现这种替换?

Check this if it`s working for you. 检查它是否适合您。

SELECT REGEXP_REPLACE((REGEXP_REPLACE('<p class="notice">...</p>','[p]','div',1,0,'c')),'(notice)','alert',1,0,'c'); 

https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=151dda40e5a5cb440ff290039bdaa917 https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=151dda40e5a5cb440ff290039bdaa917

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM