Using Regular Expressions to Rename Textbox IDs

How can you use regular expression in Find and Replace in Visual Studio to use the Textbox IDs same as your Column name in the Eval statement?

Consider the following two textboxes and there are couple of textboxes like them in the form

<cmpst:Textbox ID="txtAppNo" Text='<%#Eval("AppDate") %>' runat="server" />
 
<cmpst:Textbox ID="txtAppNo" Text='<%#Eval("NIN") %>' runat="server" />

You want to convert the IDs of the above textboxes as following

 

<cmpst:Textbox ID="txtAppDate" Text='<%#Eval("AppDate") %>' runat="server" />
 
<cmpst:Textbox ID="txtNIN" Text='<%#Eval("NIN") %>' runat="server" />

 

I took me a while to get this regular expression right, so I'm posting it here for reuse, here's how

Find

ID=\"txt(.*)\" Text=\'\<\%\#Eval\(\"{(.*)}\"\)

 

Replace

ID="txt\1" Text='<%#Eval("\1")

1 Comment

Comments have been disabled for this content.