The following hack produces a result similar to your examples:
string str = "10100011101101";
Regex rex = new Regex(@"1*100*11*");
Console.WriteLine("string str=\"{0}\"", str);
int lastend = -1;
for (int i = 0; i < str.Length; i++)
{
Match match = rex.Match(str.Substring(i));
if (match.Success)
{
int pos = match.Index + i;
int len = match.Length;
int end = pos + len - 1;
if (lastend < end)
{
Console.WriteLine("index={{{0},{1}}};//{2}", pos, end, match.Value);
}
lastend = end;
}
}
How to tell the instructor how this works? ;-)
string str="10100011101101"
index={0,2};//101
index={2,8};//1000111
index={6,11};//111011
index={10,13};//1101
Regards
Andi