For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
You mentioned this thread. 569585
Actually, This solution needs to arrange. Because '|' is separate.
declare Str varchar2(4000) := '1234|5678|1234|679134|1235|1234|679134|5678|1234|8888|888|88|888|'; begin DBMS_Output.Put_Line(Str); for i in 1..length(Str) Loop --Str := RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*?\|)\2','\1\2\3'); Str := RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3'); end Loop; DBMS_Output.Put_Line(Str); end; / 1234|5678|1234|679134|1235|1234|679134|5678|1234|8888|888|88|888| 1234|5678|679134|1235|8888|888|88|
Hi Keith Jamieson. You can make solution which you want. You can use above Regex in Model or TableFunction or Function.
Thanks Guys , Thats perfect. I have run a sample test on my data and it works perfectly. I can now run an update (a few times, but thats better than the pl/sql alternative).
I do not fully understand the syntax so will investigate it. I can sort of see whats happening.
select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from ( select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from ( select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from ( select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from ( select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from ( WITH BARCODE AS (SELECT '1234|5678|1234|679134|1235|1234|679134|5678|1234|' str FROM DUAL) --AS SELECT * FROM DUAL --SELECT bar,instr(bar,'|'),instr(bar,'|') FROM BARCODE select RegExp_Replace(Str,'(^|\|)([^|]+\|)(.*\|)\2','\1\2\3') str from barcode ) str ) ) ) )
Wow! Regex which I created is wrong. This is correct regex.
declare Str1 varchar2(4000) := '1234|5678|1234|679134|1235|1234|679134|5678|1234|8888|888|88|888|'; Str2 varchar2(4000) := '24139000191161|24139000191161|'; begin DBMS_Output.Put_Line(Str1); for i in 1..length(Str1) Loop Str1 := RegExp_Replace(Str1,'(^|\|)([^|]+\|)(.*\|)?\2','\1\2\3'); end Loop; DBMS_Output.Put_Line(Str1); DBMS_Output.Put_Line(Str2); for i in 1..length(Str2) Loop Str2 := RegExp_Replace(Str2,'(^|\|)([^|]+\|)(.*\|)?\2','\1\2\3'); end Loop; DBMS_Output.Put_Line(Str2); end; / 1234|5678|1234|679134|1235|1234|679134|5678|1234|8888|888|88|888| 1234|5678|679134|1235|8888|888|88| 24139000191161|24139000191161| 24139000191161|
By the way, I think that this regex book is very good. http://www.oreilly.com/catalog/regex3/ I have second edition of Japanese language version.