In Visual Studio 2008, using Regex, how do I comment out all lines containing the text "xyz"?
views:
112answers:
3
+1
A:
^(.*xyz.*)$
Replace with
// \0
Should do the trick I think. (Not 100% positive here... testing now)
EDIT: Fixed (it's \0 not \1).
Billy3
Billy ONeal
2010-03-01 20:24:11
A:
Find what: ^.*xyz.*
Replace with: //\0
use: Regular expressions.
Paul Creasey
2010-03-01 20:25:26
Hmm.. doens't seem to work. It works if the entire like is `xyz`, but not if `xyz` is only part of a line.
Billy ONeal
2010-03-01 20:28:33
@Billy, works exactly the same as yours in 2010 rc, which is not surprising, since it is in fact the same as your, without the redundent set of grouping parenthesis!
Paul Creasey
2010-03-01 20:31:29
Hmm.. something went really crazy then. I could have swore the regex listed was `^.xyz.` which would not do what the OP needs. The *s are not optional :P
Billy ONeal
2010-03-01 23:49:49