I'm trying to do the following operation. I have many lines of data that needs to be edited to delete a part of a string. This string contains a pattern B0ExxB+, where 'x' could be any character or number.
'1SX8+B0DSUB+B0E0LB+B0FMAB+B0G0KB'
'1SX8+B0DSUB+B0FMAB+B0G0KB'
I use the REGEXP_REPLACE operation. have two strategies to accomplish the operation:
Known the pattern B0E apply more regex operators to pick also the 4 following characters after the pattern, and then replace them by nothing.
update rx3qtxin xn set cin.cin_value = REGEXP_REPLACE (cin.cin_value, '\SB0E', '') where cin.id = 500228;
That deletes the pattern, OK. I've tried with adding as many ? after the pattern but it delete any other part of the string.
The question mark is a placeholder for a single character in Unix ("wildcard character"). In regular expressions, for the same task we use the dot (period). The question mark (in regular expression) just makes the subexpression it applies to optional. It won't help you with your task.
You need something like
regexp_replace(col, 'B0E..B\+')
Note that the "plus sign" must be escaped, since unescaped it is a metacharacter.