开发者

JS Regex allow single language input

开发者 https://www.devze.com 2023-03-15 03:16 出处:网络
I need javascript regex that will allow english or hebrew characters but not both mixed. for example: myu开发者_如何学JAVAser - OK.

I need javascript regex that will allow english or hebrew characters but not both mixed. for example:


Matches strings entirely of the Hebrew unicode range, or entirely alpha/numeric/underscore.

/^(?:[\u0590-\u05FF\uFB1D-\uFB40]+|[\w]+)$/i

Got the Hebrew unicode ranges from wikipedia.

var RE_SINGLE_LANG = /^(?:[\u0590-\u05FF\uFB1D-\uFB40]+|[\w]+)$/i;
if (!RE_SINGLE_LANG.exec(myText)) {
   alert("NOT VALID");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消