/// <summary> /// Finds ranges for given regex pattern. /// Search is separately in each line. /// This method requires less memory than GetRanges(). /// </summary> /// <param name="regexPattern">Regex pattern</param> /// <returns>Enumeration of ranges</returns> public IEnumerable <Range> GetRangesByLines(string regexPattern, RegexOptions options) { Normalize(); //create regex Regex regex = new Regex(regexPattern, options); // var fts = tb.TextSource as FileTextSource;//<----!!!! ugly //enumaerate lines for (int iLine = Start.iLine; iLine <= End.iLine; iLine++) { // bool isLineLoaded = fts != null?fts.IsLineLoaded(iLine) : true; // var r = new Range(tb, new Place(0, iLine), new Place(tb[iLine].Count, iLine)); if (iLine == Start.iLine || iLine == End.iLine) { r = r.GetIntersectionWith(this); } foreach (var foundRange in r.GetRanges(regex)) { yield return(foundRange); } if (!isLineLoaded) { fts.UnloadLine(iLine); } } }
/// <summary> /// Finds ranges for given regex pattern. /// Search is separately in each line. /// This method requires less memory than GetRanges(). /// </summary> /// <param name="regexPattern">Regex pattern</param> /// <returns>Enumeration of ranges</returns> public IEnumerable <Range> GetRangesByLines(string regexPattern, RegexOptions options) { Normalize(); //create regex Regex regex = new Regex(regexPattern, options); //enumaerate lines for (int iLine = Start.iLine; iLine <= End.iLine; iLine++) { var r = new Range(tb, new Place(0, iLine), new Place(tb[iLine].Count, iLine)); if (iLine == Start.iLine || iLine == End.iLine) { r = r.GetIntersectionWith(this); } foreach (var foundRange in r.GetRanges(regex)) { yield return(foundRange); } } }