Need Expert Help, I think with Negative Lookbehind

General questions about using TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Need Expert Help, I think with Negative Lookbehind

Post 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
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post 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 ...)
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

That was the trick, Mudguard! Many thanks! You truly Grok in Full!
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
AmigoJack
Posts: 486
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

If you guys had backslashes in your regex (i.e. dbo\.account) then those are killed by the forum software.
Post Reply