public static string getStringByRex(string txt, string rex, int index) { List <rexData> res = new List <rexData>(); rexData result = new rexData(); Match charSetMatch = Regex.Match(txt, rex, RegexOptions.IgnoreCase | RegexOptions.Multiline); while (charSetMatch.Success) { return(charSetMatch.Groups[index].Value); } return(""); }
public static rexData getrexDataByRex(string txt, string rex, int index) { if (String.IsNullOrEmpty(txt) || String.IsNullOrEmpty(rex)) { return(null); } rexData result = new rexData(); Match charSetMatch = Regex.Match(txt, rex, RegexOptions.IgnoreCase | RegexOptions.Multiline); while (charSetMatch.Success) { result.data.Add(charSetMatch.Groups[index].Value); charSetMatch = charSetMatch.NextMatch(); } return(result); }
public static List <rexData> getStringByRex(string txt, string rex, int[] index) { List <rexData> res = new List <rexData>(); rexData result = new rexData(); Match charSetMatch = Regex.Match(txt, rex, RegexOptions.IgnoreCase | RegexOptions.Multiline); while (charSetMatch.Success) { foreach (int i in index) { result.data.Add(charSetMatch.Groups[i].Value); } res.Add(result); charSetMatch = charSetMatch.NextMatch(); } return(res); }