如何使正则表达式只匹配西里尔文保加利亚字母 [英] how to make regular expression match only Cyrillic bulgarian letters

查看:146
本文介绍了如何使正则表达式只匹配西里尔文保加利亚字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想用空字符串替换bylgarian字母表中的所有字母
我看过这个链接
如何将西里尔字符与正则表达式匹配
但它对我不起作用

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

以下是我尝试过的事情

1. var newstr = strInput.replace(/[\p{IsCyrillic}]/gi, '');

不起作用!

2. var newstr = strInput.replace(/[\p{Letter}]/gi, '');

也没有
感谢您的帮助;

also nothing thanks for help;

推荐答案

Javascript不支持 \p {IsCyrillic} 形式的Unicode类。

Javascript doesn't support Unicode classes of the form \p{IsCyrillic}.

但是,假设你要替换的字符是Unicode 西里尔语范围0400 - 04FF,您可以使用:

But, assuming the characters you want to replace are in the Unicode Cyrillic range 0400 - 04FF, you could use:

newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' ); 

例如:

    var strInput = 'уфхцчшщъhelloЁЂЃЄрстыьэю',
        newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' ); 

    console.log( newstr );    //  'hello'

这篇关于如何使正则表达式只匹配西里尔文保加利亚字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆