Match SQL PRINT blocks with quoted text in it

0 views
Skip to first unread message

Jonas

unread,
Nov 26, 2009, 5:31:31 AM11/26/09
to Regex
Hi all,

I got the following text:


PRINT CONVERT(NVARCHAR, CURRENT_TIMESTAMP, 111) + ' ' + CONVERT
(NVARCHAR, CURRENT_TIMESTAMP, 108)
+ ' -Test Mode : ' + (CASE WHEN @turbo_mode_ind = 1
THEN 'some text ''test'' some more text.'

ELSE 'and even more text ''temp'' when will it stop ?' END)

PRINT 'text don''t text'

PRINT 'text ''test2'' text'


and what I need to match is:


PRINT CONVERT(NVARCHAR, CURRENT_TIMESTAMP, 111) + ' ' + CONVERT
(NVARCHAR, CURRENT_TIMESTAMP, 108)
+ ' -Test Mode : ' + (CASE WHEN @turbo_mode_ind = 1
THEN 'some text ''test''

PRINT 'text ''test2''


So basically I need to match:
* starting at PRINT
* each char that after PRINT
* inclusive line-breaks (don't stop at line-breaks)
* with \'{2}\w+\'{2} at the end of the match
* non-greedy
* AND no empty line(s) between PRINT and \'{2}\w+\'{2}

I already got this, but it still matches empty line(s):
PRINT.*?\'{2}\w+\'{2}(?!\n\s*\n)

Thx for the help

inhahe

unread,
Dec 4, 2009, 9:25:13 AM12/4/09
to re...@googlegroups.com
> --
>
> You received this message because you are subscribed to the Google Groups "Regex" group.
> To post to this group, send email to re...@googlegroups.com.
> To unsubscribe from this group, send email to regex+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/regex?hl=en.
>
>
>

huh, i dunno. i guess it would be nice if we could do something like:

PRINT(^\n\n)*?\'{2}\w+\'{2}(?!\n\s*\n)

where ^ there means 'not' sort of like in character ranges but for
arbitrarily long strings
i wonder why they don't have that.
Reply all
Reply to author
Forward
0 new messages