安卓edText编辑框禁止输入表情符号,使用正则表达式
来源:互联网 发布:美团数据采集 编辑:程序博客网 时间:2024/06/06 00:42
安卓edText编辑框禁止输入表情符号
使用正则表达式 p s f s NOT_EMOJI = “[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]”
找了好多个正则表达式,这个还是可以的
代码: 返回true代表输入了表情,否则不是表情
public static boolean isEmote(String content) { Pattern pattern = Pattern.compile(NOT_EMOJI); Matcher matcher = pattern.matcher(content); return matcher.find(); }
EdText控件监听
text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } //可以在这个方法里面操作完成 @Override public void afterTextChanged(Editable s) { //如果为true if (isEmote(s.toString())) { //删除输入的表情,开始位置和结束位置,表情符号长度为2个,所以减2 s.delete(s.length() - 2, s.length()); }else { textView.setText("(" + s.length() + "/" + "200" + ")"); } } });
阅读全文
0 0
- 安卓edText编辑框禁止输入表情符号,使用正则表达式
- ios 禁止输入表情符号
- 禁止输入各种表情符号
- 禁止输入表情符号
- Android禁止输入表情符号
- EditText禁止输入表情符号
- Android 禁止输入emoji表情符号
- Android 禁止输入emoji表情符号
- 关于iOS禁止输入表情符号
- 【代码笔记】iOS-禁止输入表情符号
- Android禁止输入表情符号的EditText
- 安卓输入框禁止输入特殊字符的需求
- EditText限制输入字数,并且禁止输入表情符号
- 安卓正则表达式
- 安卓正则表达式
- 如何禁止编辑框输入汉字CEdit
- MFC EditBox 编辑框禁止输入中文
- 禁止在EditText中输入表情及表情符号的方法
- MyBatis开发环境搭建
- Invenio安装步骤(一)
- IntelliJ IDEA中Push failed: Failed with error: unable to access xx:Unknown SSL protocol error in
- POJ:1008 JAVA
- 创建可传递的林信任,Active Directory系列之二十
- 安卓edText编辑框禁止输入表情符号,使用正则表达式
- MySQL双机热备简介实现(Windows+liunx)+liunx下MySQL数据库日常数据备份
- JS跨域问题
- WEBBASIC Unit03 CSS声明
- LVS NAT模式
- Web.Config错误页配置
- EL表达式、Servle
- Java 爬虫模拟知乎登陆
- 单变量线性同余方程的C++实现