views:

14

answers:

1

How to swap attributes ID and runat in all tags in my Visual Studio 2008 solution?

Was

<asp:Label ID="Label1" runat="server" />

became

<asp:Label runat="server" ID="Label1" />
+1  A: 

In Find and Replace, enable Use of Regular expressions.

Find what:

 ID="{[^\"]+}" runat="server"

Replace with:

 runat="server" ID="\1"

Use {} to tag sub-expressions within regular expression. The meaning of find part is: find one or more characters that aren't quotation marks after ID=" and up to next quotation mark and tag it as sub-expression.

In replace, you use \1 to denote the first sub-expression found and that's the tag id.

Edit: Add a single space character in front of search and replace expressions, to avoid matching something like: ContentPlaceHolderID="MainContent" runat="server".

Miroslav Popovic
Thanks! That is very easy and exactly what I was searching for. P.S. The same result as 'find part' you can get inserting leading space to both expression: _ID=... => _runat=...
abatishchev