Find and Replace Using Regular Expressions in Visual Studio 2013 and SQL Server Management Studio 2014

In Visual Studio, I had to replace a bunch of DropDownList ListItem states and countries from something like

<asp:ListItem id=”” value=”CO” Text=”Colorado” />


<asp:ListItem ID=”CO” value=”CO” Text=”Colorado” />

After dorking with it for a while, I found that this works:

Edit > Find and Replace

Find what:

id=”” value=”([A-Z][A-Z])”

Replace with:

ID=”$1″ value=”$1″

Be sure to check the Use Regular Expressions box.

Apparently, $1 uses the parenthesis in ([A-Z][A-Z]) to handle the replacement.


I also wanted to apply a class to the second cell in a table spanning multiple lines tab formatting in VS.

<- tab -><- tab -><- tab -><- tab -><- tab -></td><- CRLF ->

<- tab -><- tab -><- tab -><- tab -><- tab -><td class=”alignleft”>

Find what:


Replace with:

</td>\n\t\t\t\t\t<td class=”alignleft”>

It’s messy with the tab formatting in VS, but it works.


And take a data model like this:

public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }

and convert it into form fields like this:

<tr><td>Name</td><td class=”alignleft”><asp:TextBox ID=”txtName” Width=”230px” runat=”server”></asp:TextBox></td></tr>
<tr><td>Email</td><td class=”alignleft”><asp:TextBox ID=”txtEmail” Width=”230px” runat=”server”></asp:TextBox></td></tr>
<tr><td>Phone</td><td class=”alignleft”><asp:TextBox ID=”txtPhone” Width=”230px” runat=”server”></asp:TextBox></td></tr>

Find what:

public .* (.*) { get; set; }

Replace with:

<tr><td>$1</td><td class=”alignleft”><asp:TextBox ID=”txt$1″ Width=”230px” runat=”server”></asp:TextBox></td></tr>


SQL Server Management Studio does it a little differently:



public {<.*>} {<.*>}


\2 \1