views:

78

answers:

2

Is there any reason why Visual Studio uses such a strange syntax (for instance in the search/replace dialog)?

Instead of writing \s*(\w+) = new Process\(\) I have to write :b*{:a+} = new Process\(\).
I am always struggling with this syntax - especially since the normal .net syntax is the former one.

This is an incomplete comparison between the two syntaxes:

what            VS .Net comment
Tab/Spaces      :b  \s  Either tab or space 
Alphanumeric    :a  \w  ([a-zA-Z0-9]) 
Subexpression   {}  ()
Substitution    \n  $n  Substitutes the substring matched by a numbered subexpr.
Backreference   \n  \n  Matches the value of a numbered subexpression

See here (Visual studio, C#) for more informations.

Is there any reason for this? Is it historical? Is there any advantage?

A: 

My best and most honest answer is because they are Microsoft therefore they can use whatever standard they choose. Some programmer somewhere probably decided that the above syntax was clearer to them or easier to code for and therefore it became canon law.

Michael Dorgan
+5  A: 

I quote Coding Horror:

However, you're in for an unpleasant surprise when you attempt to actually use regular expressions to find anything in Visual Studio. Apparently the Visual Studio IDE has its own bastardized regular expression syntax. Why? Who knows. Probably for arcane backwards compatibility reasons, although I have no idea why you'd want to perpetually carry forward insanity. Evidently it makes people billionaires, so who am I to judge.

http://www.codinghorror.com/blog/2006/07/the-visual-studio-ide-and-regular-expressions.html

Ted
thanks for the link - the first screenshot in the article is great - it shows what happens when I push the arrow button I always overlooked and ignored ^^
tanascius