How do I get a RegEx to match "GO", but not if it's in a comment?

JustinF

New member
Joined
Dec 11, 2002
Messages
4
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
 
Ok, if nobody knows how to do this, do you know of a good regex forum or something that would be able to help me?

Thanks.
 
Back
Top