0

I need a Validator which makes sure that the Password is not less than 6 characters, I need the RegEx code for it. Thanks.

8
  • It's a bit overkill to use a RegEx for this ofcourse.. Commented Dec 16, 2012 at 19:03
  • @MichielvanVaardegem : regex are short and cool ... no more if-else conditions, loops etc required Commented Dec 18, 2012 at 10:31
  • @AmitRanjan true, but for checking a length of a string, it is overkill Commented Dec 18, 2012 at 10:35
  • @MichielvanVaardegem: Case (i) If (Regex.IsMatch(expr)) or case (ii) If(paswd.Length<6) { // some mess} else { //proceed}. ALso sometime we need extra checks for null and empty too. But Incase of regex it will do all for you.. Commented Dec 18, 2012 at 10:45
  • @AmitRanjan if(passwd == null || passwd.Length < 6){// error} What is the problem? This is way faster then the RegEx Commented Dec 18, 2012 at 11:29

1 Answer 1

3

Your regex should be ^.{6,}$.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.