regex matches with intersection in C#

Posted by StuffHappens on Stack Overflow See other posts from Stack Overflow or by StuffHappens
Published on 2010-04-20T12:29:22Z Indexed on 2010/04/20 12:33 UTC
Read the original article Hit count: 529

Filed under:
|

Hello.
I wonder if it is possible to get MatchCollection with all matches even if there's intersection among them.

            string input = "a a a";
            Regex regex = new Regex("a a");
            MatchCollection matches = regex.Matches(input);
            Console.WriteLine(matches.Count);
This code return 1, but I want it to return 2. How do achive it?
Thank you for your help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex