how to make regular expression match only Cyrillic bulgarian letters

后端 未结 3 663
夕颜
夕颜 2021-02-14 13:06

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\'

相关标签:
3条回答
  • 2021-02-14 13:47

    I think that JavaScript RegEx does not support this syntax.

    May be this will help?

    XRegExp

    0 讨论(0)
  • 2021-02-14 13:51

    Another way:

    Pattern.compile("[А-я]+", Pattern.UNICODE_CHARACTER_CLASS).matcher(strInput ).replaceAll("") ;
    

    Where [А-я]+ is your alphabet.

    0 讨论(0)
  • 2021-02-14 13:58

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

    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, '' ); 
    

    For example:

        var strInput = 'уфхцчшщъhelloЁЂЃЄрстыьэю',
            newstr = strInput.replace( /[\u0400-\u04FF]/gi, '' ); 
    
        console.log( newstr );    //  'hello'
    
    0 讨论(0)
提交回复
热议问题