我有一個文件包含大量的SQL,包括一些存儲過程。我只想提取存儲過程。 SQL可能看起來像下面的正則表達式匹配從模式直到另一個模式
SHOW PROCEDURE SECADMIN.NewTUTRMU_User_new ;
3 Rows returned. DBS time = 00:00:00
RequestText
REPLACE PROCEDURE SecAdmin.NewTUTRMU_User_new
(
IN UserName VARCHAR(128),
IN SARNumber VARCHAR(10),
)
/*
come comments
*/
BEGIN
DECLARE emOwnerDeptI VARCHAR(20);
SEL SUBSTRING(:UserName FROM 8) INTO :GDWUserid;
CALL DBC.SysExecSql('
CREATE USER '||:UserName||' ...
...
...
END;
...
Then some more SQL and then another stored procedure definition
...
SHOW PROCEDURE SECADMIN.ReInstateUser_new ;
3 Rows returned. DBS time = 00:00:00
RequestText
REPLACE PROCEDURE SECADMIN.ReInstateUser_new
(
IN UserName VARCHAR(128)
--Must be full employee ID including leading 0's
,IN Empl_I VARCHAR(12),
IN Task_Num)
/*
MODIFICATION HISTORY:
*/
BEGIN
DECLARE newPassword VARCHAR(20);
...
...
END;
...
...
我想出了以下正則表達式,它不起作用,並匹配文本,直到它找到一個分號。
REPLACE PROCEDURE.*[^;]*;
我需要一個匹配從REPLACE PROCEDURE到END的正則表達式的正則表達式;
請建議。
看看現在 –