I use regex to parse stored procedures to modify them. here is my sample text:
DECLARE @TempTable TABLE ( TempID int IDENTITY PRIMARY KEY, AMFID smallint, AppModID smallint, AppID tinyint, ModID smallint, FPID smallint, URL varchar(100), SortIndex smallint, [AppName] varchar(100), ModName varchar(100), FPName varchar(100), WUCData varchar(7000) )
...
I just want to get this part:
DECLARE @TempTable TABLE ( TempID int IDENTITY PRIMARY KEY, AMFID smallint, AppModID smallint, AppID tinyint, ModID smallint, FPID smallint, URL varchar(100), SortIndex smallint, [AppName] varchar(100), ModName varchar(100), FPName varchar(100), WUCData varchar(7000) )
Please note that this may be repeated several times. I need all the declarations of temporary tables in the text. I used the following template:
string re1 = "(Declare)( )(@)((?:[az][a-z0-9_]*))(\\s+)(Table)(\\s+)(\\(.*\\))"; Regex r = new Regex(re1, RegexOptions.Multiline | RegexOptions.IgnoreCase);
But it does not work. Any ideas?