简体   繁体   中英

Regex string replace in mysql

Is there a simple way to do the following in mysql:

"Value ( some stuff here) " --> "Value"

Something similar to 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). You'll want something like oracle's REGEXP_REPLACE

In mysql you cannot replace items of rows with regexp help. So you have to select all values "Value ( some stuff here) " from a defined column. Process them on a client-side with python facilities. After that you need update all rows in a mysql database.

Or you can read this answers How to do a regular expression replace in MySQL?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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