Arbejdsglæde
Arbejdsglæde

Reputation: 14088

Javascript test string for lower case in any language

Hi I need test javascript string for any lower latters i have build next code:

var LOWER = /[a-z]/;
var lower = LOWER.test('mystring');

but If string contain any special chars from other languages this code not working. and is is logical my test is just for English latter. How to write test for any language ?

Upvotes: 2

Views: 183

Answers (1)

simonzack
simonzack

Reputation: 20928

You can do this:

function isLowerCase(s){
    return s==s.toLowerCase()
}
isLowerCase('mystring');

toLowerCase respects the unicode standard.

Some examples:

isLowerCase('ä')==true

isLowerCase('Ä')==false

Upvotes: 7

Related Questions