Lopper
Lopper

Reputation: 3537

How can I make use of Visual Studio's regular expression to replace multiple lines of code?

Is it possible to make use of Visual Studio 2005/2008 "Find" and "Replace" functionality along with regular expression to replace multiple lines of already coded C# code into a single line of code?

Note that Visual Studio's "Find" and "Replace" regular expression syntax differs from .NET Framework.

Upvotes: 0

Views: 1421

Answers (3)

Marco Rodrigues
Marco Rodrigues

Reputation: 1

Tested:

In the find & replace dialog: Get everything between "START" and "END"

START(.|\n)*?END

Upvotes: 0

Sadhana
Sadhana

Reputation: 135

Try:

.|\n

The "." matches any character, the "\n" matches a newline character, and the "|" tells you to match either the "." or the "\n."

Upvotes: 3

Jason Kleban
Jason Kleban

Reputation: 20828

\n is the newline character in the Find & Replace syntax. Just replace \n with nothing.

Upvotes: 1

Related Questions