Monday, 15 April 2013

sql - REGEXP_REPLACE to replace list of values with list of values in single statement -



sql - REGEXP_REPLACE to replace list of values with list of values in single statement -

select regexp_replace('juheti bt mema', 'bt' ,'\bt',2) dual;

this replace escape character in front end of bt. have multiple list of words bt,sys,pt etc.. want replace (bt,sys,pt) /bt,/sys,/pt.

if word comes in middle means should replaced /bt, if syn comes means should replaced /syn.

how acheive in regexp?

i want replace list of values (bt,syn,pt) list of values (/bt,/syn,/pt)

select regexp_replace('juheti bt sys pt mema', '((bt)|(sys)|(pt))' ,'\\\1', 1) dual;

the replace_string can contain 500 backreferences subexpressions in form \n, n number 1 9. if want include backslash () in replace_string, must precede escape character, backslash.

a subexpression fragment of pattern enclosed in parentheses. subexpressions can nested. subexpressions numbered in order in left parentheses appear in pattern. example, consider next expression:

0123(((abc)(de)f)ghi)45(678)

this look has 5 subexpressions in next order: "abcdefghi" followed "abcdef", "abc", "de" , "678".

sql regex oracle replace

No comments:

Post a Comment