Click here to Skip to main content

Comments by Ronald M. Martin (Top 3 by date)

Ronald M. Martin - 29 Feb '12 - 13:06 View
So Regex("^.*?$") is not faster than Regex("\n"), as you originally stated and Regex("^.*?$") is also slower than Regex("^.*$"). The thing that originally confused me was the use of "?" as a trailing qualifier applied to quantifiers. It's syntactically odd in that it requires look ahead, much as two-character operators in C# or C++. This type of syntax is generally handled lexically, as if the character pair represents a unique character (token) in the grammar. Reading the documentation from top to bottom, I stopped when I matched "*" and "?" separately. Thanks for clearing this up for me.
Ronald M. Martin - 28 Feb '12 - 9:50 View
Let me rephrase my question. Assuming that your syntax (@"^.*?$") is valid, does it produce a different result than (@"^.*$")?
Ronald M. Martin - 27 Feb '12 - 23:27 View
I don't understand the use of the question mark (?) in this speedup. The question mark is supposed to represent 0 or 1 occurences of the previous element. In this case, I take the previous element to be the dot (.), representing any character, quantified by the star (*), representing 0 or more occurrences (of any character). I don't know what adding another quantifier (the question mark) means in this context or if it's even allowed. If it is allowed and actually helps, please explain what it does, since I'm clearly missing something.

Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid