views:

237

answers:

1

Visual Studio Find and Replace Regular Expressions

Find lines with quoted strings, not containing strings include or trace

i am tryling to find out all lines in c++ project that contains some text

as i have to use visual studio, i have to use its Find and Replace

http://www.codinghorror.com/blog/2006/07/the-visual-studio-ide-and-regular-expressions.html

so, for finding all lines like: print("abc"); it is enogh to write

:q

and it will find all quotted strings

ok, but i also get lot of lines like #include "stdio.h" and trace("* step 1 *")

i find out regex to get all lines containing include and trace

<include|trace>

so, mine question is, how to find all lines with "quotted strings" but NOT lines that contains strings include and trace.

thanx

A: 

Try this:

^~(.*<(include|trace)>).*:q

~(whatever) is how VS does negative lookahead. This matches from the start of the line to end of the last quoted string on that line. If you want to match the whole line, you can do that, too:

^~(.*<(include|trace)>).*:q.*$

Note that this will exclude lines containing the words "include" and "trace" even if they're inside a quoted string.

Alan Moore