MariaDB longtext REGEXP_REPLACE()-替换单元格中所有给定参数变量值的出现

时间:2019-02-06 20:25:03

标签: regex replace sql-update mariadb

我正在尝试使用以下参数和值更新一个充满url对象的longtext列:

UPDATE table SET column = REGEXP_REPLACE(column,'tid4=[a-z]+','tid4=NEW_VALUE');

这将清空包含参数的单元格,而不是替换该单元格中所有出现的参数,无论该值是多少(只要按字母顺序排列)都使用与我设置的值相同的参数即可。有什么想法我做错了吗?如何替换整个单元格中所有出现的字符串?

谢谢!

更新:

示例单元格内容:

a:45:{s:4:"post";s:2:"on";s:8:"postself";s:0:"";s:4:"page";s:2:"on";s:8:"pageself";s:0:"";s:7:"comment";s:0:"";s:6:"lposts";s:2:"on";s:6:"lpages";s:0:"";s:5:"lcats";s:0:"";s:5:"ltags";s:0:"";s:6:"ignore";s:13:"about,contact";s:10:"ignorepost";s:8:"contact,";s:8:"maxlinks";i:3;s:9:"maxsingle";i:1;s:8:"minusage";i:1;s:9:"customkey";s:27851:"game, games, gaming| https://url.tld/XXX.php?sub_id=&tid1=111&tid2=222&tid3=3333&tid4=firsttest
testing, testing2| https://url.tld/XXX.php?tid1=111&tid2=222&tid3=333&tid4=secondtest
test word, word2| https://url.tld/XXX.php?tid1=111&tid2=2222&tid3=333&tid4=thirdtest";s:30:"customkey_preventduplicatelink";N;s:6:"nofoln";s:0:"";s:6:"nofolo";s:0:"";s:6:"blankn";s:0:"";s:6:"blanko";s:0:"";s:10:"onlysingle";s:2:"on";s:8:"casesens";s:0:"";s:9:"allowfeed";s:0:"";s:12:"maxsingleurl";s:1:"1";s:7:"samecat";s:2:"on";s:11:"urltemplate";s:29:"<a href="{url}">{keyword}</a>";s:10:"utfsupport";s:0:"";s:17:"disable_texturize";s:0:"";s:10:"match_slug";s:0:"";s:11:"limit_posts";i:500;s:19:"customkey_form_file";s:0:"";s:17:"append_or_replace";N;s:8:"base_url";s:2:"go";s:4:"time";i:1549483409;s:14:"visual_kw_edit";N;s:16:"custom_separator";s:1:",";s:10:"min_length";i:5;s:12:"check_plural";N;s:20:"add_instead_override";s:0:"";s:18:"nofollow_whitelist";s:0:"";s:13:"maxtotallinks";i:0;s:16:"limit_post_order";s:5:"title";s:15:"limit_post_sort";s:3:"asc";s:8:"skipdays";i:0;s:10:"trimspaces";s:2:"on";}

我必须使tid4=whatevervalue的所有出现都变成tid4=thesamevalue

我还有其他要替换的东西,例如.php?tid1= to .php?subid=&tid1= then this to .php?sub_id=newvalue&tid1=

0 个答案:

没有答案