Joe White’s Blog

Life, .NET, and Cats


*Real* regex search-and-replace in Visual Studio

niugang just posted some very cool code on CodeProject: a Visual Studio add-in that gives you real regex search and replace.

It’s long annoyed me that Visual Studio’s regex support is so weird. They have a lot of the features, but their syntax is truly, truly warped. ({} for captures? @ and # and ^ for quantifiers? Needing to either roll a manual character class, or else understand the full Unicode spec, just to do something simple like \w?) And they’re missing some of the most interesting and useful features, like lookbehind and positive lookahead. Which is silly, because they have full-fledged Perl-compatible regular expressions sitting right there in the Framework.

Okay. Enough ranting. This add-in should be way cool. Unfortunately, niugang had to create all new UI, since there was no way to reuse the standard Visual Studio search and replace dialogs. This probably means some of the fancier features are missing (I suspect that I won’t be able to select two different directories and tell it to search them both, for example). But even so, I’m very much looking forward to real regexes in VS. And hey, it’s got source code.

Now someone just needs to write a real regex search-and-replace for Delphi…

2 Responses to “*Real* regex search-and-replace in Visual Studio”

  1. Robert MacLean Says:

    A few things I found for Delphi are

    http://www.pcre.org/

    and .Net (Nick Hodges is going to love me for pumping .Net) has a full regular expression library built in, which is easy to call from D8/D2005

  2. Joe White Says:

    Yeah, I already said .NET has a full PCRE regex library. What I’m wondering is when the Delphi IDE’s Find and Find In Files and Replace will be upgraded to actually *use* those real regexes.

    (Y’know, I should write this up as an enhancement in QC…)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Joe White's Blog copyright © 2004-2008. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS).