Page 1 of 1

Need Expert Help, I think with Negative Lookbehind

Posted: Thu Jul 22, 2021 7:54 pm
by kengrubb
I'm trying to match on a SQL INSERT statement, but only up to the first GO statement. I think I need Negative Lookbehind assist, but I could not make it work.

This will keep finding until the LAST GO statement, but I only want the NEXT GO statement after the INSERT.
insert +into +dbo.account .*GO

Posted: Thu Jul 22, 2021 8:55 pm
by MudGuard
maybe ungreediness might help (hard to say without the text you want to match).

Ungreedy version of your regex:

Code: Select all

insert +?into +?dbo.account .*?GO
(i.e. add a ? to the quantifiers + or * where you don't want greedy version ...)

Posted: Thu Jul 22, 2021 10:57 pm
by kengrubb
That was the trick, Mudguard! Many thanks! You truly Grok in Full!

Posted: Fri Jul 23, 2021 8:27 am
by AmigoJack
If you guys had backslashes in your regex (i.e. dbo\.account) then those are killed by the forum software.