using System;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
string str = @"stackoverflow(stack:stackoverflow)overstackflow(over:stackoverflow)";
IList<String> foundStrings = new List<String>();
int currentIndex = 0;
int index = str.IndexOf("(", currentIndex);
while (index != -1)
{
int start = index + "(".Length;
int colonIndex = str.IndexOf(":", start);
if (colonIndex != -1)
{
string nextFound = str.Substring(start, colonIndex - start);
foundStrings.Add(nextFound);
}
currentIndex = start;
index = str.IndexOf("(", currentIndex);
}
foreach(string found in foundStrings)
Console.WriteLine(found);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCSAgICBzdHJpbmcgc3RyID0gQCJzdGFja292ZXJmbG93KHN0YWNrOnN0YWNrb3ZlcmZsb3cpb3ZlcnN0YWNrZmxvdyhvdmVyOnN0YWNrb3ZlcmZsb3cpIjsKICAgICAgICAgICAgSUxpc3Q8U3RyaW5nPiBmb3VuZFN0cmluZ3MgPSBuZXcgTGlzdDxTdHJpbmc+KCk7CiAgICAgICAgICAgIGludCBjdXJyZW50SW5kZXggPSAwOwogICAgICAgICAgICBpbnQgaW5kZXggPSBzdHIuSW5kZXhPZigiKCIsIGN1cnJlbnRJbmRleCk7CiAgICAgICAgICAgIHdoaWxlIChpbmRleCAhPSAtMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IHN0YXJ0ID0gaW5kZXggKyAiKCIuTGVuZ3RoOwogICAgICAgICAgICAgICAgaW50IGNvbG9uSW5kZXggPSBzdHIuSW5kZXhPZigiOiIsIHN0YXJ0KTsKICAgICAgICAgICAgICAgIGlmIChjb2xvbkluZGV4ICE9IC0xKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyBuZXh0Rm91bmQgPSBzdHIuU3Vic3RyaW5nKHN0YXJ0LCBjb2xvbkluZGV4IC0gc3RhcnQpOwogICAgICAgICAgICAgICAgICAgIGZvdW5kU3RyaW5ncy5BZGQobmV4dEZvdW5kKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0YXJ0OwogICAgICAgICAgICAgICAgaW5kZXggPSBzdHIuSW5kZXhPZigiKCIsIGN1cnJlbnRJbmRleCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yZWFjaChzdHJpbmcgZm91bmQgaW4gZm91bmRTdHJpbmdzKQogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoZm91bmQpOwoJfQp9