SoFunction
Updated on 2025-04-07

Android EdText edit box prohibits the input of emojis (using regular expressions)

Use the regular expression p s f s NOT_EMOJI = "[\ud83c\udc00-\ud83c\udffff]|[\ud83d\udc00-\ud83d\udffff]|[\u2600-\u27ff]"

I found many regular expressions, this is OK

Code: Returning true means that the expression was entered, otherwise it is not an expression.

 public static boolean isEmote(String content) {
  Pattern pattern = (NOT_EMOJI);
  Matcher matcher = (content);
  return ();
 }

EdText control listening

(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) {
   }
   //It can be done in this method   @Override
   public void afterTextChanged(Editable s) {
    //If true    if (isEmote(())) {
     //Delete the input emoticon, start position and end position, the emoticon length is 2, so reduce 2     (() - 2, ());
    }else {
     ("(" + () + "/" + "200" + ")");
    }
   }
  });

The above is the Android EdText edit box that the editor introduced to you forbidden emoji input (using regular expressions). I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!