sql assistant regex backreference support

General

sql assistant regex backreference support

Using SQL Assistant 15.10.0305

 

I have statements in my code such as:


drop table M_B_v2

 

I want to replace all occurences of drop table (.*) with /* drop table (.*) */, i.e., I want to comment out any drop table statement.

This is what I tried in the SQL Assistant editor:

 

search:
^drop(.*)
replace:
/* drop\1 */

produces

/* drop 1 */
so it's not recognizing the backreference.

any suggestions/help would be greatly appreciated!

 

Tags (1)
2 REPLIES
Teradata Employee

Re: sql assistant regex backreference support

Hi prooney2,

 

I've never paid attention to this option in the editor, since I mostly use Notepad++ to edit my SQL code.

 

I've searched a bit, $n is the syntax to refer a block, so go for /* drop$1 */ in your replace string and it will work.

 

But maybe you could have used a non regexp replace : "drop" to "-- drop" for the same purpose.

 

Re: sql assistant regex backreference support

Thank you so much!  $1 works.

I had only seen backreferencing done with \1.

I suppose there are many flavors of regular expression metacharacters!