FileStream fWrite = new FileStream("test.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.None);
class Program {
static void Main(string[] args) {
string longer = "kokokoko<!3oleg!3>lololo[2!dom2!]";
string name = SearchWordInMassive(longer, "!3"); //longer1
string adress = SearchWordInMassive(longer, "2!"); //longer2
}
private static string SearchWordInMassive(string massiveWords,string restrictionCharacters) {
string word = "";
int startIndex = massiveWords.IndexOf(restrictionCharacters) + restrictionCharacters.Length;
int lastIndex = massiveWords.LastIndexOf(restrictionCharacters);
int lengthWord = lastIndex - startIndex;
word = massiveWords.Substring(startIndex, lengthWord);
return word;
}
}