Tuesday, April 13, 2010

It's been a while!

Some Visual Studio regular expressions I've found useful recently:

To replace your lazy Response.Write statements with something a little more correct:
Find: Response\.Write\({.#}\);
Replace: Results.Text += \1;
(Or stringBuilder.Append(\1); or whatever is appropriate.)

To find textboxes (Html.TextBox from the ASP.NET MVC helpers, and standard input elements) that don't have a maxlength set. Works on single lines only.
(Html\.TextBox|input type="text")~(.#maxlength)
(Replace maxlength with any other text for other properties.)

I found this Knol by Brian Lalonde very useful in creating these regular expressions (and I love the snarky ending paragraph).

No comments: