Regular expressions in Visual Studio’s find and replace can save a lot of time.
For a recent project, we used a DetailsView bound to an ObjectDataSource generated by SubSonic. The bound fields were almost, but not quite, what we needed. They were quickly updated with some regular expression magic.
The DetailsView has camel-cased text for the field names and the header text.
<Fields>
<asp:BoundField DataField="CustomerBase" HeaderText="CustomerBase"
SortExpression="CustomerBase" />
<asp:BoundField DataField="AffiliateMarketing" HeaderText="AffiliateMarketing"
SortExpression="AffiliateMarketing" />
[... and lots of other fields]
</Fields>
</asp:DetailsView>
With a little search and replace magic in Visual Studio 2008, spaces can be added to the HeaderText:
![clip_image001[3] clip_image001[3]](http://blog.solien.com/images/blog_solien_com/WindowsLiveWriter/StandbackIknowregularexpressions_DCE0/clip_image001%5B3%5D_thumb.gif)
The regular expression is:
{HeaderText="[a-Z0-9 ]#[A-z0-9]}{(:Lu|[0-9])}{[^"]#"}
The replacement pattern is:
\1 \2\3
The results:
<Fields>
<asp:BoundField DataField="CustomerBase" HeaderText="Customer Base"
SortExpression="CustomerBase" />
<asp:BoundField DataField="AffiliateMarketing" HeaderText="Affiliate Marketing"
SortExpression="AffiliateMarketing" />
[... and lots of other fields]
</Fields>
</asp:DetailsView>