How to Replace Emoji Characters in a Java String Using Regular Expressions?

Linda Hamilton
Release: 2024-11-25 20:35:19
Original
915 people have browsed it

How to Replace Emoji Characters in a Java String Using Regular Expressions?

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]
    }
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template