Example is like this one - I tried to match seasons like summer 2004 or spring 05. Pattern I made worked fine until I jump into problems when more then one option is listed in input string, like spring summer 2005.
First pattern: (?
Input Value: spring 2005
Matches: spring 2005
First pattern: (?
Input Value: spring summer 2005
Matches: summer2005
In this case I wanted spring 2005 to be matched. With listed pattern that is not possible. Since summer is listed after spring match for spring can not be found by the engine. I had to find a way to skip word summer somehow.
After several different tests I found solution. What I realized is that in input string I have 2 times following pattern (pseudo code) - season + whitespace. From that point it was easy to find make appropriate pattern.
Input Value: spring summer 2005
Matches: spring summer 2005.
Keep in mind that Season group has in this case two captures (for spring and summer) and in order to spring value you need to call first item in captures collection, like:
m.Groups["Season"].Captures[0].Value.
Also, captures property works fine when there is only one match.
Every time when you get unexpected results from regex engine analyze what are reasons for unexpected result and you will understand better engine that works under regular expressions in .Net.
One great reference for RegEx I use every time when I need to parse some strings:
http://www.regular-expressions.info
Bye until next tip I found :)