Hey everyone, I am picking up C# and I was wondering if anyone had an "ExtractAll" function for C# that they could post here with example usage. Thanks
Close this thread. Code (Text): public string[] GrabAllBetween(string strSource, string strStart, string strEnd) { List<string> Matches = new List<string>(); for (int pos = strSource.IndexOf(strStart, 0), end = pos >= 0 ? strSource.IndexOf(strEnd, pos) : -1; pos >= 0 && end >= 0; pos = strSource.IndexOf(strStart, end), end = pos >= 0 ? strSource.IndexOf(strEnd, pos) : -1) { Matches.Add(strSource.Substring(pos + strStart.Length, end - (pos + strStart.Length))); } return Matches.ToArray(); } credits to cx323