Q:

Validating a password input that contains arabic characters using Javascript

I currently validate my english based password field using the following method which contains a regex pattern.
/**
 * Validates password based on following rules: 
 * Must contain a lowercase letter
 * Must contain a Uppercase letter
 * Must contain a number
 * Must be longer than 8 chars
 * Can contain special chars
 */
exports.isValidPassword = function (password) {    
    var pattern = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/;
    var result = pattern.test(password);
    return result;
};

I have a new requirement in which I need to support Arabic languages, how could I accomplish this while still keeping my current rules? I have seen in the past where people put {arabic} in the regex pattern, but I'm not sure if that's the right approach for my case. 

A:

[\u0621-\u064A] should match any letter in the Arabic alphabet.
Adding this to the range of allowed characters in your regex should do.
Note that Arabic does not have upper and lower case letters the way the Latin alphabet does, so you will have to think about how to define your password requirements with that in mind.

