Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:04:26+00:00 2026-06-09T23:04:26+00:00

Fast question, i’m using NSPredicate to verify passwords, I already use this code for

  • 0

Fast question, i’m using NSPredicate to verify passwords, I already use this code for the username:

-(BOOL)isUserValid:(NSString *)checkString{
    NSString       *filter = @"[A-Z0-9a-z]{5,40}";
    NSPredicate *evaluator = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", filter];
    return [evaluator evaluateWithObject:checkString];
}

But now on the password i would like to allow the user to use special characters such as “@”, “$”, “&”, “*”.

How can i do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:04:27+00:00Added an answer on June 9, 2026 at 11:04 pm

    I don’t know you needs exactly how many characters or specified characters allow to user. but, according to your question example, if you want to allow the user only @,$,&,* characters. refer a following code.

    -(BOOL)isUserValid:(NSString *)checkString{
        NSString       *filter = @"[A-Z0-9a-z@$&*]{5,40}";
        NSPredicate *evaluator = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", filter];
        return [evaluator evaluateWithObject:checkString];
    }
    

    following filter code is one of the popular password expreesion. alphanumeric characters and select special characters. The password also can not start with a digit, underscore or special character and must contain at least one digit.

    Matches password1 | pa$$word2 | pa!@#$%3

    Non-Matches password | 1stpassword | $password#

    -(BOOL)isUserValid:(NSString *)checkString{
            NSString       *filter = @"^(?=[^\\d_].*?\\d)\\w(\\w|[!@#$%]){5,40}";
            NSPredicate *evaluator = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", filter];
            return [evaluator evaluateWithObject:checkString];
        }
    

    and more expression filter about password. see the site: regexlib_password

    following reference is You’ll help while you are working. and remember a following Expression about Character and Bracket.

    Character Classes
    
    .   Matches any character except newline. Will also match newline if single-line mode is enabled.
    \s  Matches white space characters.
    \S  Matches anything but white space characters.
    \d  Matches digits. Equivalent to [0-9].
    \D  Matches anything but digits. Equivalent to [^0-9].
    \w  Matches letters, digits and underscores. Equivalent to [A-Za-z0-9_].
    \W  Matches anything but letters, digits and underscores. Equivalent to [^A-Za-z0-9_].
    \xff    Matches ASCII hexadecimal character ff.
    \x{ffff}    Matches UTF-8 hexadecimal character ffff.
    \cA Matches ASCII control character ^A. Control characters are case insensitive.
    \132    Matches ASCII octal character 132.
    
    Bracket Expressions
    
    [adf?%] Matches characters a or d or f or ? or %.
    [^adf]  Matches anything but characters a, d and f.
    [a-f]   Match any lowercase letter between a and f inclusive.
    [A-F]   Match any uppercase letter between A and F inclusive.
    [0-9]   Match any digit between 0 and 9 inclusive. Does not support using numbers larger than 9, such as [10-20].
    
    [:upper:]   Matches uppercase letters. Equivalent to A-Z.
    [:lower:]   Matches lowercase letters. Equivalent to a-z.
    [:alpha:]   Matches letters. Equivalent to A-Za-z.
    [:alnum:]   Matches letters and digits. Equivalent to A-Za-z0-9.
    [:ascii:]   Matches ASCII characters. Equivalent to \x00-\x7f.
    [:word:]    Matches letters, digits and underscores. Equivalent to \w.
    [:digit:]   Matches digits. Equivalent to 0-9.
    [:xdigit:]  Matches characters that can be used in hexadecimal codes. Equivalent to A-Fa-f0-9.
    [:punct:]   Matches punctuation.
    [:blank:]   Matches space and tab. Equivalent to [ \t].
    [:space:]   Matches space, tab and newline. Equivalent to \s.
    [:cntrl:]   Matches control characters. Equivalent to [\x00-\x1F\x7F].
    [:graph:]   Matches printed characters. Equivalent to [\x21-\x7E].
    [:print:]   Matches printed characters and spaces. Equivalent to [\x21-\x7E ].
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've already looked at questions git rebase and git push: non-fast forward, why use?
Well fast question is there any way to use a css class in a
inHi, this question is fast, but from my point of view its pretty hard.
This is a simple question that can be answered fast by someone who's more
Thanks to this question/answer Automatic Reference Counting: Error with fast enumeration I resolved a
Fast question I am comparing a String, should I use equals or compareTo? because
Hi Just a fast question. I am trying to use System.ComponentModel.DataAnnotations in .NET to
in this question Why is this F# code so slow? , it is discussed
This question came up when I was thinking about the algorithm to fast compute
Well this question relates to MVVM pattern and i could good and fast answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.