private ParamCollection Parse(ref string s, string pattern, bool remove, string tag, RegexOptions options) { ParamCollection cmd = new ParamCollection(Name); Regex rex = new Regex(pattern, options); Match m1 = rex.Match(s); while (m1.Success) { string param = m1.Groups[PARAM].Value; string arg = m1.Groups[ARGS].Value; if (param != null) { param = param.TrimEnd(' '); ArgCollection prm = cmd.Add(param, new ArgCollection(param, tag)); if (arg != null) { arg = arg.TrimEnd(' '); if (!string.IsNullOrEmpty(arg)) { prm.Add(arg); } } } if (remove) { s = s.Remove(m1.Index, m1.Length).Trim(); m1 = rex.Match(s); } else { m1 = rex.Match(s, m1.Index + m1.Length); } } return(cmd); }
protected string Match(ref Regex rex, ref ParamCollection result, ref Match m, string s, string group, string tag) { string file_name = m.Groups[group].Value.Trim(); result.Add(file_name, new ArgCollection(file_name, tag)); s = s.Remove(m.Index, m.Length).Trim(); m = rex.Match(s); return(s); }