예제 #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));
 }
예제 #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));
        }
예제 #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);
        }
예제 #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);
 }
예제 #5
0
 public static Regex ToRegex(this IRegex c)
 {
     return(new Regex(c.GetValue(), RegexOptions.Compiled));
 }
예제 #6
0
 public static bool IsMobile(this IRegex c)
 {
     return(RegexHelper.IsMobile(c.GetValue()));
 }
예제 #7
0
 //常用正则
 public static bool IsEmail(this IRegex c)
 {
     return(RegexHelper.IsEmail(c.GetValue()));
 }
예제 #8
0
 public static Regex ToRegex(this IRegex c, RegexOptions opts)
 {
     return(new Regex(c.GetValue(), opts));
 }