Answer the question
In order to leave comments, you need to log in
How to get multiple parts of text from string?
Let's say I have the following:
string long = "kfkfkkfppepd0d03k31word=1<3!oleg!3>1flakoekfml2laz[-1dom3-]"
string long_part1 = "";
string long_part2 = "";
Answer the question
In order to leave comments, you need to log in
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;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question