i'm using oracle10g version 10.2.0
OS Windows7
Have a requirement where in i need to replace the occurrence of numbers followed '%' sign into XX symbol in a given string which looks this '10% of CIF + 5% of CIF'.
Using the REG_EXP_REPLACE like this:
- Code: Select all
SELECT REGEXP_REPLACE('10% of CIF + 5% of CIF','([[:digit:]]+\%?)','XX%',1,1) REGEXT_SAMPLE
FROM DUAL;
OUTPUT: XX% of CIF + 5% of CIF
SELECT REGEXP_REPLACE('10% of CIF + 5% of CIF','([[:digit:]]+\%?)','XX%',1,2) REGEXT_SAMPLE
FROM DUAL;
OUTPUT: 10% of CIF + XX% of CIF
This gives proper result when there are no decimal digits.
But even if the string contains numbers like this '10% of CIF + 5.5% of CIF' it should work.
Have tried changing the pattern as below, which doesn't solve the puporse
- Code: Select all
SELECT REGEXP_REPLACE('10% of CIF + 5.5% of CIF','(([[:digit:]]|([[:digit:]].[[:digit:]]))+\%?)','XX%',1,2) REGEXT_SAMPLE
FROM DUAL;
OUTPUT:10% of CIF + XX%.5% of CIF
Please help me on this