Example #1
0
        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("");
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }