internal Int32 AddResult(String rest, Int32 index) { var restResult = new regexMarkerResult(rest, index, defaultMarker); AddResult(restResult); return(restResult.index + restResult.length); }
public regexMarkerResult GetResult(String scrambled) { Match m = test.Match(scrambled); regexMarkerResult res = new regexMarkerResult(m, marker); res.regexMarker = this; return(res); }
internal void AddResult(regexMarkerResult res) { for (Int32 ind = res.index; ind <= res.index + res.length; ind++) { byAllocation.Add(ind, res); } byMarker.Add(res.marker, res); }
public List <regexMarkerResult> GetResults(String scrambled) { List <regexMarkerResult> output = new List <regexMarkerResult>(); MatchCollection mchs = test.Matches(scrambled); foreach (Match m in mchs) { regexMarkerResult res = new regexMarkerResult(m, marker); res.regexMarker = this; output.Add(res); } return(output); }
/// <summary> /// Gets the marker results by order of appearance -- taking only first layer /// </summary> /// <returns></returns> public List <regexMarkerResult> GetByOrder() { List <regexMarkerResult> output = new List <regexMarkerResult>(); Int32 index = 0; regexMarkerResult head = null; while (index < length) { if (byAllocation.ContainsKey(index)) { var tmp = byAllocation[index].First(); output.Add(tmp); index = index + tmp.length; } else { index++; } } return(output); }
/// <summary> /// Processes the specified text input into <see cref="regexMarkerResultCollection{T}"/> /// </summary> /// <param name="input">The input text to be parsed</param> /// <returns>Collection with matched results</returns> public regexMarkerResultCollection process(String input) { regexMarkerResultCollection output = new regexMarkerResultCollection(); String scrambled = input; if (SerialMode) { Boolean matchFound = true; do { matchFound = false; foreach (var reg in Markers) { if (reg != null) { Match m = reg.test.Match(scrambled); if (m.Success) { regexMarkerResult res = new regexMarkerResult(m, reg.marker); output.AddResult(res); scrambled = reg.ReplaceMatch(m, scrambled); matchFound = true; } } } } while (matchFound); } else { foreach (var reg in Markers) { if (reg != null) { MatchCollection mchs = reg.test.Matches(scrambled); foreach (Match m in mchs) { regexMarkerResult res = new regexMarkerResult(m, reg.marker); output.AddResult(res); } scrambled = reg.test.Replace(scrambled, reg.replacementGenerator); } } } String[] rest = scrambleCut.Split(scrambled); Int32 index = 0; regexMarkerResult restResult = null; foreach (String rst in rest) { if (output.byAllocation.ContainsKey(index)) { index = index + output.byAllocation[index].First().match.Length; } else { index = output.AddResult(rst, index); } } output.length = index; return(output); }