[英]Regex string replace in mysql
Is there a simple way to do the following in mysql: 有没有一种简单的方法可以在mysql中执行以下操作:
"Value ( some stuff here) " --> "Value"
Something similar to REPLACE("(*)","")
? 类似于
REPLACE("(*)","")
吗? How would I go about doing this and stripping the remaining whitespace? 我将如何去做并剥离剩余的空白?
Try: 尝试:
"/s*/(.*/)/s*"
This will match leading whitespace, the text in parenthesis and trailing whitespace. 这将匹配前导空格,括号内的文本和尾随空格。
Look at UDFs(user defined functions). 查看UDF(用户定义的函数)。 You'll want something like oracle's REGEXP_REPLACE
您将需要像Oracle的REGEXP_REPLACE之类的东西
In mysql you cannot replace items of rows with regexp help. 在mysql中,您无法使用regexp帮助替换行项目。 So you have to select all values "Value ( some stuff here) " from a defined column.
因此,您必须从定义的列中选择所有值“ Value(此处有一些东西)”。 Process them on a client-side with python facilities.
使用python工具在客户端上处理它们。 After that you need update all rows in a mysql database.
之后,您需要更新mysql数据库中的所有行。
Or you can read this answers How to do a regular expression replace in MySQL? 或者您可以阅读此答案如何在MySQL中执行正则表达式替换?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.