New Regex / C # question:
Consider (. *) = (. *) And how it will correspond to "A = B = C"
I am exepected to get two matching objects back, as there are two ways to group and match:
(A = B) = (C)
or
(A) = (B = C)
However, I return only one matching object (the first case). Therefore, I think I don’t understand why the collection of matches is a collection, since I cannot get more than one item. Can someone explain?
fyi - for the above test, I just used the "immediate" window:
?Regex.Matches("A = B = C", "(.*)=(.*)").Count
1
?Regex.Matches("A = B = C", "(.*)=(.*)")[0].Groups[1].Captures[0]
Value: "A = B"
?Regex.Matches("A = B = C", "(.*)=(.*)")[0].Groups[1].Captures[1]
Value: "C"
source
share