user2831001
user2831001

Reputation: 135

RegEx.Test returns always false

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()));
});

Upvotes: 1

Views: 257

Answers (1)

anubhava
anubhava

Reputation: 785146

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

Upvotes: 1

Related Questions