I need a regex that validates for minimum 7 digits in the given string
.net, c#, regex, validation
Solution
Seven or more digits, mixed with any number of any other kind of character? That doesn't seem like a very useful requirement, but here you go:
^\D*(?:\d\D*){7,}$
Problem
I wanna validate a phone number. My condition is that I want mimimum 7 numbers in the given string, ignoring separators, X, parantheses. Actually I want to achieve this function in regex: ``` Func<string, bool> Validate = s => s.ToCharArray().Where(char.IsDigit).Count() >= 7; Func<string, bool> RegexValidate = s => System.Text.RegularExpressions.Regex.IsMatch(s, @"regex pattern should come here.") string x = "asda 1234567 sdfasdf"; string y = "asda sdfa 123456 sdfasdf"; bool xx = Validate(x); //true bool yy = Validate(y); //false ``` The purpose of my need is I want to include this regex in an asp:RegularExpressionValidator