Jk041
Jk041

Reputation: 982

Visual Studio Regex with negation not working

I'm trying to do a Regex for Visual Studio search that finds me all the calls to the methods of a certain class that don't use callback (the class is a proxy, and I want to find the synchronous calls).

I want to find this kind of calls:

jc.GetStuff (data1, data2, data3);

But not this:

jc.GetStuff (data1, data2, data3, GetStuffCallback);

So I'm trying with this:

~(<jc>..*<(>.*<Callback>.*<)>)<jc>..*<(>.*<)>

and, not knowing if I should escape those parenthesis:

~(<jc>..*<\(>.*<Callback>.*<\)>)<jc>..*<\(>.*<\)>

I can't figure why this isn't working... what am I missing? Thanks!

Upvotes: 0

Views: 114

Answers (1)

rrrr-o
rrrr-o

Reputation: 2516

I'm not sure what all of the angle brackets are in your expression, but how about something like this?

jc\..+\((?!.*Callback.*).*\);

 

jc                   literal string jc
\.                   full stop (escaped)
.*                   any character 1 or more times
\(                   opening bracket (escaped)
(?!.*Callback.*)     negative lookahead for callback
.*                   any character 0 or more times
\(                   closing bracket (escaped)
;                    literal string ;

Upvotes: 1

Related Questions