检查字母是否是表情符号 [英] Check if letter is emoji

查看:206
本文介绍了检查字母是否是表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一封信是否是表情符号。我发现了一些类似的问题并找到了这个正则表达式:

I want to check if a letter is a emoji. I've found some similiar questions on so and found this regex:

private final String emo_regex = "([\\u20a0-\\u32ff\\ud83c\\udc00-\\ud83d\\udeff\\udbb9\\udce5-\\udbb9\\udcee])";

然而,当我在以下句子中执行以下操作时:

However, when I do the following in a sentence like:

for (int k=0; k<letters.length;k++) {    
    if (letters[k].matches(emo_regex)) {
        emoticon.add(letters[k]);
    }
}

它不会添加任何表情符号的任何字母。我也尝试使用 Matcher 模式,但这也不起作用。正则表达式是否有问题,或者我在代码中遗漏了哪些东西?

It doesn't add any letters with any emoji. I've also tried with a Matcher and a Pattern, but that didn't work either. Is there something wrong with the regex or am I missing something obvious in my code?

这就是我收到这封信的方式:

This is how I get the letter:

这篇关于检查字母是否是表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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