The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, Sandeep.
Asked: November 10, 2015 - 9:57 pm UTC
Last updated: November 12, 2015 - 2:02 am UTC
Version: 12c
Viewed 1000+ times
with t as ( select '"ABCDEFDDDD ""SSFD"""' str from dual ) select regexp_replace( regexp_replace( regexp_replace(str,'^"',''), -- replace " at start with nothing '"$',''), -- replace " at end with nothing '""+','"') -- 2 or more " with a single from t;
Vladislav, November 11, 2015 - 5:24 am UTC
select replace(regexp_replace('"ABCDEFDDDD ""SSFD"""','"(.*)"','\1'),'""','''''') str from dual;
cd, November 11, 2015 - 6:38 am UTC
select regexp_replace('"ABCDEFDDDD ""SSFD"""', '^"|"$|"(")', '\1') str from dual
STR ----------------- ABCDEFDDDD "SSFD"
Tim, November 11, 2015 - 11:50 am UTC
SELECT REPLACE(REPLACE(REPLACE(REPLACE( reverse( SUBSTR( reverse( SUBSTR('"ABCDEFDDDD """"""""""""""""SSFD"""', 2) --get pos 2 to end ) --reverse it , 2) --get pos 2 to the end again ) --reverse it back , '"""""','"'), '""""', '"'), '"""', '"'), '""', '"') --get rid of the duplicate quotes FROM dual; result : ABCDEFDDDD "SSFD"
Sandeep, November 11, 2015 - 10:44 pm UTC
select replace( substr('"ABCDEFDDDD ""SSFD"""',2,length('"ABCDEFDDDD ""SSFD"""')-2),'""','"')from dual;
Stew Ashton, November 12, 2015 - 12:27 pm UTC
with data as ( select '"ABCDEFDDDD ""SSFD"""' txt from dual ) select replace(trim('"' from txt), '""', '"') from data
Stew Ashton, November 12, 2015 - 2:38 pm UTC
Duke Ganote, November 12, 2015 - 2:48 pm UTC
WITH parms AS ( SELECT '"' as dlm -- delimiter to be de-duplicated , '@' as tmp -- temporary substitution FROM DUAL ) , instring AS ( SELECT 'ABCDEFDDDD """"""""""""""""SSFD""' as qsv FROM dual ) , trimmed_ends AS ( SELECT reverse( SUBSTR( reverse( SUBSTR(qsv, 2) --get pos 2 to end ) --reverse it , 2) --get pos 2 to the end again ) --reverse it back as qsv FROM instring ) SELECT REPLACE( REPLACE( REPLACE( qsv ,dlm ,dlm||tmp) ,tmp||dlm ,'' ) ,dlm||tmp ,dlm ) as FROM trimmed_ends CROSS JOIN parms; REPLACE(REPLACE( ---------------- BCDEFDDDD "SSFD"
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!