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.
- Input example (string) :
'1SX8+B0DSUB+B0E0LB+B0FMAB+B0G0KB' - Desired output :
'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.
- Main idea.
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.
- Known left pattern (B0E) and right pattern (B+) delete where both patterns are matched and the content between them.
- No idea how to apply that idea in regex.*
REGEXP_REPLACE(col, 'B0E[[:alnum:]]{2}B[+]', '')?\Sin the regular expression in your attempt? There is no mention of it in the problem description.BBExxB+? TryREGEXP_REPLACE('1SX8+B0DSUB+B0E0LB+B0FMAB+B0G0KB', '(^|\+)B0E[[:alnum:]]{2}B\+(B0E[[:alnum:]]{2}B\+)*', '\1')then (it also matches consecutive occurrences).