Esempio n. 1
0
 public static bool IsMatch(this IRegex c, string pattern, RegexOptions opts)
 {
     if (c.GetValue().IsNullOrEmpty())
     {
         return(false);
     }
     return(Regex.IsMatch(c.GetValue(), pattern, opts));
 }
Esempio n. 2
0
        public static string Replace(this IRegex c, string parent, string replaceMent, int count, int startAt, RegexOptions opts)
        {
            var reg = parent.As <IRegex>().ToRegex(opts);

            if (count <= 0)
            {
                return(reg.Replace(c.GetValue(), replaceMent));
            }
            return(startAt >= 0
                ? reg.Replace(c.GetValue(), replaceMent, count, startAt)
                : reg.Replace(c.GetValue(), replaceMent, count));
        }
Esempio n. 3
0
        public static IEnumerable <string> Matches(this IRegex c, string parent, string groupName, RegexOptions opts)
        {
            var list = new List <string>();

            if (c.GetValue().IsNullOrEmpty())
            {
                return(list);
            }
            var ms = Regex.Matches(c.GetValue(), parent, opts);

            list.AddRange(from Match m in ms select m.Groups[groupName].Value);
            return(list);
        }
Esempio n. 4
0
 public static string Match(this IRegex c, string pattern, string groupName, RegexOptions opts)
 {
     return(c.GetValue().IsNullOrEmpty() ? string.Empty : Regex.Match(c.GetValue(), pattern, opts).Groups[groupName].Value);
 }
Esempio n. 5
0
 public static Regex ToRegex(this IRegex c)
 {
     return(new Regex(c.GetValue(), RegexOptions.Compiled));
 }
Esempio n. 6
0
 public static bool IsMobile(this IRegex c)
 {
     return(RegexHelper.IsMobile(c.GetValue()));
 }
Esempio n. 7
0
 //常用正则
 public static bool IsEmail(this IRegex c)
 {
     return(RegexHelper.IsEmail(c.GetValue()));
 }
Esempio n. 8
0
 public static Regex ToRegex(this IRegex c, RegexOptions opts)
 {
     return(new Regex(c.GetValue(), opts));
 }