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!
windows 7 64bit. 4GB Ram. Core I5.
Hi,
I used many versions of sql developer and I always feel it's slow in everything. Is there a light weight version of it or is there something I can do to make it faster?
SQL> ed Wrote file afiedt.buf 1 with t as (select 'a, b, c (x, y, z)' as txt from dual) 2 -- 3 select txt, replace(regexp_replace(txt, '(^,)*\(.*\)','\1'),',')||regexp_replace(txt,'.*(\(.*\))','\1') as new_txt 4* from t SQL> / TXT ----------------- NEW_TXT -------------------------------------------------------------------------------- a, b, c (x, y, z) a b c (x, y, z)
WITH t AS (SELECT 'a, b, c (x, y, z)' col1 FROM dual) SELECT t.col1 , REGEXP_REPLACE(t.col1, '(\(.*\))|,', '\1') new_col FROM t ; COL1 NEW_COL ----------------- -------------------- a, b, c (x, y, z) a b c (x, y, z)
Hi cd and BluShadow,
Thanks very much for your valuable help!
One other question - what if I want to replace the non-() enclosed commas with another string - such as "#". I tried your suggestion and got this:
WITH t AS (SELECT 'a, b, c (x, y, z)' col1 FROM dual) SELECT t.col1 , REGEXP_REPLACE(t.col1, '(\(.*\))|,', '\1') cds_awesome_solution , REGEXP_REPLACE(t.col1, '(\(.*\))|,', '#\1') pdaddys_futile_attempt1 , REGEXP_REPLACE(t.col1, '(\(.*\))|,', '\1#') pdaddys_futile_attempt2 FROM t ;
Result:
"COL1" "CDS_AWESOME_SOLUTION" "PDADDYS_FUTILE_ATTEMPT1" "PDADDYS_FUTILE_ATTEMPT2" "a, b, c (x, y, z)" "a b c (x, y, z)" "a# b# c #(x, y, z)" "a# b# c (x, y, z)#"
Notice how the pound is place before the left paren in attempt1 and placed after the right paren in attempt2? I know I could nest another regexp_replace - but I was wondering if a single pattern could suffice...
Thanks - and sorry I didn't make my question clear at all in my original post...
You guys ARE geniuses
WITH t AS (SELECT 'a, b, c (x, y, z)' col1 FROM DUAL) SELECT t.col1, REPLACE(REGEXP_REPLACE(t.col1, '(\(.*\))|(,)', '\1\2\2'), ',,', '#') new_col FROM t; COL1 NEW_COL ----------------- -------------------- a, b, c (x, y, z) a# b# c (x, y, z)