SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[SA 7.2.338 Pro] - Advanced Text Processor

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[SA 7.2.338 Pro] - Advanced Text Processor
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post [SA 7.2.338 Pro] - Advanced Text Processor Reply with quote
I was experimenting with Advanced Text Processor but I found no way forcing it to detect a regexp for a certain scenario.

There are PRINTs in a stored procedure that obstructs some php scripts so I decided to make them optional by adding 'IF @debug = 1' in front of PRINTs. First I tried "(?<!IF @debug = 1[\s\n\r]*)PRINT" but it turned out Negative lookbehind do not support repetitions or variable lengths inside. So I tried "IF @debug = 1[\s\n\r]*?PRINT" with "IF @debug = 1 PRINT" followed by a "(?<!IF @debug = 1 )PRINT" + "IF @debug = 1 PRINT" but it does not seem to work. Any hints on how to make it change its mind?
Tue Sep 01, 2015 9:52 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Here is how to do that


Fri Sep 04, 2015 1:38 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post Reply with quote
Magnificent, thank you very much. But it still does not solve the issue with lookbehind. The code might already be formatted this way:
Code:

IF @debug = 1
    PRINT @table_structure


And then I'll end up with

Code:

IF @debug = 1
    IF @debug = 1 PRINT @table_structure


EDIT:
It seems that I managed to accomplish it by turning them back to simple PRINTs first with
Code:

-- Find text
^(\s*)IF\s*@debug\s*=\s*1\s*PRINT
-- Replace text
\1PRINT


followed by

Code:

-- Find text
^(\s*)PRINT
-- Replace text
\1IF @debug = 1 PRINT

Fri Sep 04, 2015 2:31 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Great. Glad you find a workaround for that.

I've got a suggestion from my team that the same result could be achieved simpler by using one rule and in a single pass, without a need to remove previous IF @debug = 1 PRINT first.

First rule could be simplified:

Code:
-- Find text
IF\s*@debug\s*=\s*1\s*PRINT
-- Replace text
\0


If there is already "IF @debug = 1" - just replace it with the same text - that's the \0 reference. In this case formatting of already masked statements will remain the same.
Fri Sep 04, 2015 8:30 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post Reply with quote
Thank you, I'll modify it accordingly
Fri Sep 04, 2015 5:12 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.