Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 isn't a "GO" in any comments. I have no idea how to tell RegEx to ignore "GO" if it's 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...