android非法字符的判定、表情符號的判定

記錄一下,以便後續自己查看


               public void onTextChanged(CharSequence s, int start,
                        int before, int count) {
                    if (s.toString().length() <= 0
                            || s.toString().matches(".*[/\\\\:*?\"<>|\t].*")  || s.toString().matches(".*\\p{So}.*")) {	//jimbo rep for bug 13191
                          //   || s.toString().matches(".*[/\\\\:*?\"<>|\t].*")) {
                       // characters not allowed
                        //if (count>=0&&s.toString().substring(start).matches(".*[/\\\\:*?\"<>|\t].*")) {
                        if (count>=0&&s.toString().substring(start).matches(".*[/\\\\:*?\"<>|\t].*") || s.toString().substring(start).matches(".*\\p{So}.*")) {	//jimbo rep
                            mToastHelper
                                    .showToast(R.string.invalid_char_prompt);
                        }
                   }
							}

其中   ".*\\p{So}.*" 是判斷表情符號



發佈了37 篇原創文章 · 獲贊 22 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章