简体   繁体   English

如何在MySQL中使用此字符串替换

[英]How can I use this string replace in MySQL

I'm using Wordpress and have a load of custom fields where I need to do a string replace on. 我使用的是Wordpress,并且有很多自定义字段,需要在其中进行字符串替换。 Basically I have a price field which is in the example format: from 113.800 基本上我有一个价格字段,其格式示例:从113.800

I need to remove the word 'from', the space after it and the dot between the number. 我需要删除单词“ from”,其后的空格以及数字之间的点。 All the fields are in this format, how can I use a MySQL replace function to do this? 所有字段都采用这种格式,我如何使用MySQL替换功能来做到这一点?

Thanks 谢谢

REPLACE() doesn't support regular expression matching, so you'll have to do it in a more clumsy way: REPLACE()不支持正则表达式匹配,因此您必须以一种更加笨拙的方式进行:

UPDATE wp_sometable
SET price_field = REPLACE(REPLACE(price_field, 'from ', ''), '.', '');

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

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