Objective-C RegEx-Password-Check is always true

I want to check the password's complexity with regular expression. But it returns always true?

The password's complexity is the following. Allowed are:

  • A-Z
  • a-z
  • 0-9
  • special characters: - _ , ; . : # + * ? = ! § $ % & / ( ) @
  • No blank characters

Here is my code:

NSString *regExPwd = @"[a-zA-Z_0-9\\-_,;.:#+*?=!§$%&/()@]+";
NSPredicate *pwdCheck = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regExPwd];
bool isValid = [pwdCheck evaluateWithObject:txtPassword.text];

Hope you can help me once again :)

Answers


You should require that there are only allowed characters from the beginning to the end:

NSString *regExPwd = @"^[a-zA-Z_0-9\\-_,;.:#+*?=!§$%&/()@]+$";

Need Your Help

Close hover div only when clicked outside block

javascript jquery css

I have got a loginbox (blue) that opens when you hover over the text login (Yellow). The box stays open when you go to the loginbox but it closes when you leave it (Mouse in the green area).

Excel Cell Format in JasperReport Report

java excel jasper-reports

I'm working on JasperReport Report that generates Excel file. For some reason my cell formats/types are not how they should be. For example I have Date object in my cell but when I generate Excel f...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.