views:

74

answers:

4

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!

+1  A: 

Try

(?!<DocumentState)\.IsSet

The ?!< is a "negative lookbehind".

Cheeso
A: 

Try this :

^\.IsSet

^ : means beginning of the string.

Matthieu
A: 
~(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.

Helen
A: 

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
Nicolas Dorier