Question

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);
Was it helpful?

Solution

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top