using System; using System.Collections.Generic; using System.Text; namespace WmHmailserverExporterWeb { public class Tools { public static string getStringInBetween(string startStr, string endStr, string source, ref int iterator) { // first try to find the first string int startIndex = source.IndexOf(startStr, iterator, StringComparison.CurrentCultureIgnoreCase); if (startIndex != -1) { // whoopie! we've found something int startPosition = startIndex + startStr.Length; int endIndex = source.IndexOf(endStr, startPosition, StringComparison.CurrentCultureIgnoreCase); if (endIndex != -1) { int length = endIndex - startPosition; if (length <= 0) { return null; } iterator = endIndex; string returnString = source.Substring(startPosition, length); return returnString; } else { return null; } } else { // nothing found, return null to give that signal return null; } } } }