javaunicodedecodeunicode-stringunicode-escapes

how to filter out specific char(unicode like U+1F603 ) in a string in java


I'd like to filter out some char who's unicode somekind like U+1F603 with java lauguage. They are all kinds of information in the string,only filter the specific char.How?Can any one help? Thanks.


Solution

  • U+1F603 character can be written as \uD83D\uDE03 in Java.

    If you have your text in String yourString variable, following code should remove occurrences of the special character.

    yourString.replace("\uD83D\uDE03", "");