public static IEnumerable <int> Parse(string stringToParse) { var format = new InputFormat(stringToParse); var numbers = format.GetNumbersToParse() .Replace("\\n", "\n") .Split(DelimitersParser.Parse(format), StringSplitOptions.None) .Select(Transform) .Where(NotGreaterThanOneThousand); CheckForNegativeNumbers(numbers); return(numbers); }
public static IEnumerable <int> Parse(string stringToParse, Options options) { var format = new InputFormat(stringToParse); var delimiters = options.Delimiter != null ? new string[] { options.Delimiter } : DelimitersParser.Parse(format); var numbers = format.GetNumbersToParse() .Replace("\\n", "\n") .Split(delimiters, StringSplitOptions.None) .Select(Transform) .Where(i => NotGreaterThanUpperBound(i, Convert.ToInt32(options.MaxInt))); if (options.NoNegativeNumbers) { CheckForNegativeNumbers(numbers); } return(numbers); }