sql - Replacing a String between two anchor points -


i trying find way replace string in between 2 "anchor points" in varchar2 column.

these "anchors" <? , ?> , want remove (replace '') between 2 symbols.

i've tried playing around replace() function, e.g. stuff select replace(my_varchar2_column,'<? % ?>') my_table; , using % operator wildcard, didn't work. no error thrown, result wasn't expected, in the replace function interpreting % literally , not wildcard.

does have idea how achieve replacement this?

example current content of column:

text want keep <? cryptic stuff in betweeen ?> text want keep well

by replacing in between <? , ?> want remove whole passage columns text. expected result this:

text want keep text want keep well

you can use regexp_replace functionality of oracle.

first argument = column needs replaced.

second argument = substring search replacement.

third argument = text replaced ( note : if omit argument, matched substrings deleted

select  regexp_replace('text want keep <? cryptic stuff in betweeen ?> text ','<\?.*\?>')  dual 

output:

text want keep  text  

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -