I need to parse a string, which contains SQL commands, for the batch terminator ("GO"). I came up with "\s[Gg][Oo]\s" which seems to work as long as there isnt a "GO" in any comments. I have no idea how to tell RegEx to ignore "GO" if its either in a line comment (--) or within a block comment (/* */). Any RegEx gurus know how to do this?
For example, the following "GO"s should be ignored
select * from Customers
-- go
select * from Customers
/*
go
*/
select * from Customers
But this should return a match:
select * from Customers
go
select * from Customers
For example, the following "GO"s should be ignored
select * from Customers
-- go
select * from Customers
/*
go
*/
select * from Customers
But this should return a match:
select * from Customers
go
select * from Customers