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 Visual .NET Comment
Studio
----------------------------------------------------------------
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 subexpression.
Backreference \n \n Matches the value of a numbered
subexpression.
----------------------------------------------------------------
See here (Visual Studio, C#) for more information.
Is there any reason for this? Is it historical? Is there any advantage?
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
The good news:
Since Visual Studio 2013, the search uses standard .NET regular expressions:
Visual Studio uses .NET Framework regular expressions to find and replace text. For more information about .NET regular expressions, see .NET Framework Regular Expressions. Before Visual Studio 2012, Visual Studio used custom regular expression syntax in the Find and Replace windows. See Visual Studio Regular Expression Conversions for an explanation of how to convert some of the more commonly-used custom regular expression symbols to the .NET versions.
No need anymore to learn a strange regular expression flavour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With