Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
Richard MacCutchan31-Dec-20 23:13
mveRichard MacCutchan31-Dec-20 23:13 
GeneralRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
BillWoodruff1-Jan-21 0:00
professionalBillWoodruff1-Jan-21 0:00 
GeneralRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
Richard MacCutchan1-Jan-21 0:24
mveRichard MacCutchan1-Jan-21 0:24 
AnswerRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
Gerry Schmitz31-Dec-20 9:15
mveGerry Schmitz31-Dec-20 9:15 
GeneralRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
BillWoodruff31-Dec-20 22:58
professionalBillWoodruff31-Dec-20 22:58 
GeneralRe: i have a problem in treeview Additional information: Index was outside the bounds of the array. Pin
Gerry Schmitz2-Jan-21 9:28
mveGerry Schmitz2-Jan-21 9:28 
QuestionWCF Service doesn't return data Pin
Member 1483009827-Dec-20 6:00
Member 1483009827-Dec-20 6:00 
QuestionRegEx Not Properly Matching Pin
#realJSOP26-Dec-20 3:07
mve#realJSOP26-Dec-20 3:07 
I'm trying to use regex to determine if a given stored proc body contains destructive sql clauses.

Here's my regex pattern (I want it to match if it contains a "select...from", but not match if it contains any of the destructive sql keywords shown):

C#
"^(?=.*SELECT.*FROM)(?!.*(?:CREATE|DROP|UPDATE|INSERT|ALTER|DELETE|ATTACH|DETACH|TRUNCATE)).*$"


Here's the string I'm passing into the regex:

SQL
PROCEDURE [dbo].[GetAlertsForApp]
(
@appShortName nvarchar(16)
)
AS
BEGIN
SET NOCOUNT ON;
declare @appID int = (SELECT ID FROM dbo.Applications WITH(NOLOCK) WHERE AppShortName = @appShortName);
select [ID],[AlertName],[AlertTitle],[AlertMsg],[AlertStartDate],[AlertExpireDate],[AlertType],[AlertClassLevel]
,[AlertApps],[ActionName],[ControllerName],[DateAdded],[AddedByUMSUserID]
FROM [dbo].[Alerts] WITH(NOLOCK)
WHERE (UPPER(AlertApps) LIKE '%' + UPPER(@appShortName) + '%' OR UPPER(AlertApps) = 'ALL')
AND AlertExpireDate IS NULL OR AlertExpireDate > GETDATE() ;
END


My problem is that the regex does not result in a match. The string above does not contain any of the prohibited words, and does include a select statement. I'm confused, and maybe just a little bench blind (and not real experienced with regex)...
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

AnswerRe: RegEx Not Properly Matching Pin
OriginalGriff26-Dec-20 4:09
mveOriginalGriff26-Dec-20 4:09 
GeneralRe: RegEx Not Properly Matching Pin
#realJSOP26-Dec-20 4:26
mve#realJSOP26-Dec-20 4:26 
GeneralRe: RegEx Not Properly Matching Pin
OriginalGriff26-Dec-20 5:08
mveOriginalGriff26-Dec-20 5:08 
GeneralRe: RegEx Not Properly Matching Pin
#realJSOP26-Dec-20 5:26
mve#realJSOP26-Dec-20 5:26 
GeneralRe: RegEx Not Properly Matching Pin
Richard Deeming4-Jan-21 22:28
mveRichard Deeming4-Jan-21 22:28 
AnswerRe: RegEx Not Properly Matching Pin
Gerry Schmitz26-Dec-20 14:54
mveGerry Schmitz26-Dec-20 14:54 
AnswerRe: RegEx Not Properly Matching Pin
jschell29-Dec-20 6:46
jschell29-Dec-20 6:46 
GeneralRe: RegEx Not Properly Matching Pin
#realJSOP30-Dec-20 3:16
mve#realJSOP30-Dec-20 3:16 
AnswerRe: RegEx Not Properly Matching Pin
Richard Deeming4-Jan-21 22:37
mveRichard Deeming4-Jan-21 22:37 
Questionsource code Pin
Member 1503068825-Dec-20 23:41
Member 1503068825-Dec-20 23:41 
AnswerRe: source code Pin
Sandeep Mewara25-Dec-20 23:51
mveSandeep Mewara25-Dec-20 23:51 
QuestionData format for non-computerist editing Pin
trønderen22-Dec-20 10:23
trønderen22-Dec-20 10:23 
AnswerRe: Data format for non-computerist editing Pin
OriginalGriff22-Dec-20 11:05
mveOriginalGriff22-Dec-20 11:05 
GeneralRe: Data format for non-computerist editing Pin
trønderen22-Dec-20 14:26
trønderen22-Dec-20 14:26 
GeneralRe: Data format for non-computerist editing Pin
BillWoodruff22-Dec-20 15:17
professionalBillWoodruff22-Dec-20 15:17 
GeneralRe: Data format for non-computerist editing Pin
trønderen23-Dec-20 8:24
trønderen23-Dec-20 8:24 
GeneralRe: Data format for non-computerist editing Pin
BillWoodruff23-Dec-20 8:42
professionalBillWoodruff23-Dec-20 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.