Use a regex to match emoji characters in a string. For example:
import java.util.regex.Pattern; public class ReplaceEmojis { public static void main(String[] args) { String text = "That's a nice joke ??? ?"; String replaced = text.replaceAll("[\p{Extended_Pictographic}]", "[e]"); System.out.println(replaced); // That's a nice joke [e][e][e] [e] } }
The above is the detailed content of How to Replace Emoji Characters in a Java String Using Regular Expressions?. For more information, please follow other related articles on the PHP Chinese website!