Hello I want to replace all the letters from bylgarian alphabet with empty string I've seen this link How to match Cyrillic characters with a regular expression but it doesn't work for me
你好,我想用空字符串替换bylgarian字母表中的所有字母,我见过这个链接如何用正则表达式匹配Cyrillic字符,但对我来说行不通
Here is what I've tried
这是我试过的
1. var newstr = strInput.replace(/[\p{IsCyrillic}]/gi, '');
doesn't work!
不工作!
2. var newstr = strInput.replace(/[\p{Letter}]/gi, '');
also nothing thanks for help;
也不感谢你的帮助;
3 个解决方案
#1
13
Javascript doesn't support Unicode classes of the form \p{IsCyrillic}
.
Javascript不支持表单\p{IsCyrillic}的Unicode类。
But, assuming the characters you want to replace are in the Unicode Cyrillic range 0400 - 04FF, you could use:
但是,假设您想要替换的字符在Unicode Cyrillic范围0400 - 04FF中,您可以使用:
newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' );
For example:
例如:
var strInput = 'уфхцчшщъhelloЁЂЃЄрстыьэю',
newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' );
console.log( newstr ); // 'hello'
#2
2
I think that JavaScript RegEx does not support this syntax.
我认为JavaScript RegEx不支持这种语法。
May be this will help?
这会有帮助吗?
XRegExp
#3
1
Another way:
另一种方法:
Pattern.compile("[А-я]+", Pattern.UNICODE_CHARACTER_CLASS).matcher(strInput ).replaceAll("") ;
Where [А-я]+
is your alphabet.
[А-я]+你的字母。
#1
13
Javascript doesn't support Unicode classes of the form \p{IsCyrillic}
.
Javascript不支持表单\p{IsCyrillic}的Unicode类。
But, assuming the characters you want to replace are in the Unicode Cyrillic range 0400 - 04FF, you could use:
但是,假设您想要替换的字符在Unicode Cyrillic范围0400 - 04FF中,您可以使用:
newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' );
For example:
例如:
var strInput = 'уфхцчшщъhelloЁЂЃЄрстыьэю',
newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' );
console.log( newstr ); // 'hello'
#2
2
I think that JavaScript RegEx does not support this syntax.
我认为JavaScript RegEx不支持这种语法。
May be this will help?
这会有帮助吗?
XRegExp
#3
1
Another way:
另一种方法:
Pattern.compile("[А-я]+", Pattern.UNICODE_CHARACTER_CLASS).matcher(strInput ).replaceAll("") ;
Where [А-я]+
is your alphabet.
[А-я]+你的字母。