Derek Lakin

Multiline RegEx Replace in Visual Studio

I was just going through our codebase to update a lengthy copyright statement to a much shorter up to date version and found it tricky to match over multiple lines. I wanted to go from something like this:

// <copyright file="SomeFile.cs" company="Contoso">
// A whole bunch more text.
// </copyright>

to this:

// © 2014 Contoso. All rights reserved.

After a little spelunking I eventually found that the following does just what I needed:

Find what: // <copyright file=".*"<strong>(.*n)+?</strong>.*</copyright>

Replace with: // © 2014 Contoso. All rights reserved.

Hope someone else finds this useful :)

development visualstudio