Why is there a difference between .NET regular expressions and Visual Studio regular expressions?

I finally found links to Visual Studio regular expressions for search and replace and the .NET regular expressions package , and now, due to painful curiosity, I want to know: why the difference !?

I'm sure there is a technical, historical or usable reason, but it confused the bajeepers [sp? ;-)] from me at first.

+6
regex visual-studio-2010
source share
2 answers

I would suggest that VS regular expressions are designed to fit the code well, with many convenient shortcuts, such as :w for the whole word, or :i for the C ++ identifier, or :q for the quoted string.

Usually they do not need to process arbitrary data, for which you will need search queries, etc. Or at least it was lower on the priority list.

+4
source share

Adapted from Visual Studio regex link

Note: There are many syntax differences between regular expressions that you can use in "Find what and replace" with those that are valid in .NET. Framework programming. For example, in the "Find and Replace" window, curly braces {} are used to indicate replace tags: each occurrence does not change this, you would use the find {it} expression and replace the expression \ 1 no. This regular expression syntax is different from the .NET Framework, where the notation {} is used for quantifiers, so the expression zo {1} will match all occurrences of z, followed by exactly one, as in a zone, but not in a zoo.

The main differences are syntactic, although Visual Studio tries to slip into a bit more functionality than the standard Regular Expression library uses.

0
source share

All Articles