How do I access matched objects for replacement when using regular expression mode in PL/SQL Developer Find & Replace?
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 ma开发者_运维百科tch. 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
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...
You can replace it using $ and number like, $0 or $1 etc. see an example below
find: TABLE (.*\..*) IS
replace: COLUMN $1 IS
http://regexr.com/3gm6c
精彩评论