views:

38

answers:

1

I have a query where I want to replace

avg(j2)

with

avg(case when j2 <> 0 then j2 else 0 end)

The above is a specific example but the pattern is the same with all the replacements. It's always a word followed by a number that needs to be replaced with the case statement that checks if the number is not 0.

I tried the following for find:

avg(\(\w\d\))

and the find works. Now, I want to do a replace so I try:

avg(case when \1 <> 0 then \1 else 0 end)

but it puts literal \1 and not the captured text from the match. I tried \\1 & $1 as well and it takes all of them literally. Can anyone tell me what the right syntax is for using the captured text for replacement? Is this supported?

Thanks,

Ashish

A: 

I am not sure if the PL/SQL Developer IDE supports group capture. The recent versions do seem to support regex based find and replace though. Cant find a source to confirm if group capture works. Why dont you try pasting the code in a something like Notepad++ and try the same regex. It should work. You could paste the result back to your IDE and continue from there...

Jass