Reputation: 13
I have a column that stores C# codes, how do I remove the last 3 parameters of the "FunctionA"? Note that the column contains multiple functions, but I only need to replace "FunctionA" using PL/SQL, I know REGEXP_REPLACE might do the trick, but I can't seem to find a way to match/replace it.
Before:
Test=FunctionA(varID, 1234,"", A.B,"","","last");
Test=FunctionA(varID, 9876,"", C.D);
Test=FunctionB(varID, 5555,"", E.F,"","","last");
After:
Test=FunctionA(varID, 1234,"", A.B);
Test=FunctionA(varID, 9876,"", C.D);
<- should not affect this
Test=FunctionB(varID, 5555,"", E.F,"","","last");
<- should not affect this
Upvotes: 1
Views: 379
Reputation: 521239
Try finding this pattern:
(,[^,]*,[^,]*,[^,]*\);)$
And then replace with just );
. Here is a sample query:
SELECT
REGEXP_REPLACE ('Test=FunctionA(varID, 1234,"", A.B,"","","last");',
'(,[^,]*,[^,]*,[^,]*\);)$', ');') AS output
FROM dual
WHERE col LIKE 'Test=FunctionA(%'
Test=FunctionA(varID, 1234,"", A.B);
Edit: I added a WHERE
clause which checks the function name.
Upvotes: 1