user150528
user150528

Reputation: 507

Regular expression search in files, in the Visual Studio editor

I was trying to search for ".IsSet", but not "DocumentState.IsSet", in VS 2008 using regular expression search. How do I compose the regular expression?

Thanks!

Upvotes: 2

Views: 1026

Answers (4)

Helen
Helen

Reputation: 98011

~(DocumentState)\.IsSet

will match all .IsSet instances that do not follow DocumentState. To match exactly .IsSet but not .IsSetFoo, you can either use

~(DocumentState)\.IsSet>

or check the Match whole word option.

See Regular Expressions (Visual Studio) for a list of regular expression tokens supported in the Visual Studio search.

Upvotes: 1

Nicolas Dorier
Nicolas Dorier

Reputation: 7475

I don't know if you can with the VS Search, but you can

  1. Replace DocumentState.IsSet by a token (like "DOCSTATE")
  2. Replace all .IsSert
  3. Replace your token "DOCSTATE" with DocumentState.IsSet

Upvotes: 0

Matthieu
Matthieu

Reputation: 2761

Try this :

^\.IsSet  

^ : means beginning of the string.

Upvotes: 0

Cheeso
Cheeso

Reputation: 192627

Try

(?!<DocumentState)\.IsSet

The ?!< is a "negative lookbehind".

Upvotes: 2

Related Questions