RegEx.Test returns always false

user2831001

The problem is that when I try to test it it returns always false. Do you have any idea why?

$('MyInput').mouseout(function () {
    alert($('MyInput').val()); // it is  "яяqqåå"
    alert(/^[\p{L}0-9\s\.\\\/\-]{2,20}$/.test($('MyInput').val()));
});
anubhava

It is because Javascript regex doesn't support \p{L}

even this returns false:

/^\p{L}+/.test('a');

You can use this blanket unicode range to match your input text:

/^[\u0000-\uffff\d\s.\\\/-]{2,20}$/.test('яяqqåå');
//=> returns true

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related