Regex in javascript workin with cyrillic (russian) set

Is it possible to work with Russian characters in javascript regex?
Perhaps using \ p {Cyrillic}?

If yes, provide a basic use case.

Example:

var str1 = "  ";
var regexp = new RegExp("[]\\b", "g");

 alert(str1.replace(regexp, "X"));

I expect to receive: abX prX

+5
source share
3 answers

It should work if you just save the JavaScript file in UTF8. Then you should be able to enter any character in the string.

edit Just made a quick example with some crooked Wikipedia characters:

var cryllic = '';
cryllic.match( '.+' )[0];
// returns as expected: ""
+6
source

JavaScript . JavaScript 16 , RegExp , , "\ b", "\ d", "\ w", ascii. , - '\ b'. , .

+6

this:

JavaScript, Unicode RegExp , \uFFFF Unicode .

, , , ( ).

.

+1
source

All Articles