I am writing an update query where I need to update some values in a column using REGEXP_REPLACE function.
I had written the below query which works correctly.
update my_table_name
set column_name = REGEXP_REPLACE(column_name, '"MyValue":0', '"MyValue":2' )
WHERE column_id=1234;
However, after – "MyValue": it can be any number ranging from 0-9. So I am trying to have a check such that it match the first string i.e. – "MyValue": and anything number after that and if that matches the next value will be whatever I will be replacing it with.
Basically I need to match the string – "MyValue:" and any digit that comes after that in the REGEX_REPLACE
Any suggestions. Should I be using REGEX_REPLACE or something else. OR the regex needs some tweaking
>Solution :
You may use REGEXP_REPLACE as follows:
UPDATE my_table_name
SET column_name = REGEXP_REPLACE(column_name, '"MyValue":[0-9]', '"MyValue":2')
WHERE column_id = 1234;