J
Justin F
I'm developing a tool that will be used to write queries against a database.
The word 'GO' is used as a batch terminator...for example, two queries
separated by 'GO' would need to be sent to the database separately. I can
can accomplish this if 'GO' appears on it's own line, but that won't always
be the case...it may be in a comment or contained in a string, in which case
I don't want to match.
Here are some examples of when I DON'T want to match 'GO':
On a commented line ('--' marks a commented line):
select * from users
-- don't match this go
select * from users2
Within a comment block ('/*' opens the block, and '*/' closes it):
select * from users
/*
don't match this go
*/
select * from users2
Within a string (single qoutes delimit a string):
select 'don't match this go'
DO match these two:
select * from users go select * from users2
select * from users
go
select * from users2
I really don't know much about regular expressions...can this be
accomplished with one? If so, what would the expression look like?
-Justin
The word 'GO' is used as a batch terminator...for example, two queries
separated by 'GO' would need to be sent to the database separately. I can
can accomplish this if 'GO' appears on it's own line, but that won't always
be the case...it may be in a comment or contained in a string, in which case
I don't want to match.
Here are some examples of when I DON'T want to match 'GO':
On a commented line ('--' marks a commented line):
select * from users
-- don't match this go
select * from users2
Within a comment block ('/*' opens the block, and '*/' closes it):
select * from users
/*
don't match this go
*/
select * from users2
Within a string (single qoutes delimit a string):
select 'don't match this go'
DO match these two:
select * from users go select * from users2
select * from users
go
select * from users2
I really don't know much about regular expressions...can this be
accomplished with one? If so, what would the expression look like?
-Justin