문제

I'm developing web-app with asp.net+js and stuck on regexp which works like a charm small test but absolutely doesn't works as expected in app.

Here's link to fiddle http://jsfiddle.net/#&togetherjs=sSzwzBe62Q. Here's the example words to try: слово, Слово, Пример. (word, Word, Example - russian).

Code should delete any word except the first one from inputs in left column. It works for latin but doesn't work for cyrillic. Any suggestions?

Perfectly working short example:

var rx = /[\wА-Яа-яЁё]+/;
var text = "Слово Word";
document.body.innerHTML = rx.exec(text);
도움이 되었습니까?

해결책

Try to specify the ranges as unicode ranges.

I'm not very familiar with cyrillic, so I'm going to base my answer on http://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode:

/[\w\u0400-\u04ff\u0500-\u052f\ua640-\ua69f\u1d2b-\u1d78]+/.exec("Слово Word");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top