Click here to Skip to main content
15,881,882 members

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

Ronald M. Martin 29-Feb-12 13:06pm View    
Deleted
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:50am View    
Deleted
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:27pm View    
Deleted
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.