21 March 2007

Visual Studio Find using RegEx

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaargh!

Why couldn't Microsoft make the regex search use some existing regex dialect? Maybe they did (randomly!) pick one, but it's not the regex dialect they use in the .NET Framework.

I admit to always finding another way when faced with searching for something like the following lines (which happens to be a task for me today), but I'm keen to do it more easily:

CREATE PROCEDURE

CREATE    PROCEDURE



So using Microsoft's VS.NET syntax, it's this:

^create:Zs+procedure

That's good to know: :Zs is a SPACE, and :Zs+ is ONE OR MORE SPACES. And if I want to find these:

CREATE  TABLE

CREATE    FUNCTION

CREATE VIEW



It's this:

^create:Zs+:w

So :Zs+:w is ONE OR MORE SPACES FOLLOWED BY A WORD.

And I'm going to refer back to this post because I won't remember this two months from now.

No comments: