I've finally found references to both Visual Studio's regular expressions for Find and Replace, and .NET's regular expression package, and now out of morbid curiousity I want to know: why the difference!?
I'm sure there's a technical, historical, or usability reason, but it confused the bajeepers [sp? ;-) ] out of me at first.
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation.
*1 , * is greedy - it will match all the way to the end, and then backtrack until it can match 1 , leaving you with 1010000000001 . . *? is non-greedy. * will match nothing, but then will try to match extra characters until it matches 1 , eventually matching 101 .
In . NET, regular expression patterns are defined by a special syntax or language, which is compatible with Perl 5 regular expressions and adds some additional features such as right-to-left matching. For more information, see Regular Expression Language - Quick Reference.
There are also two types of regular expressions: the "Basic" regular expression, and the "extended" regular expression. A few utilities like awk and egrep use the extended expression. Most use the "basic" regular expression. From now on, if I talk about a "regular expression," it describes a feature in both types.
I'd speculate that the VS regexes are designed to match code well, having defined lots of handy shortcuts like :w
for an entire word, or :i
for a C++ identifier, or :q
for a quoted string.
They usually don't need to handle arbitrary data that you'd need lookaround assertions and stuff like that for. Or at least that was lower on the priorities list.
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