How to Replace for multibyte character in java

834 views Asked by At

I want to convert the multibyte space. Is there any way through which i can convert this into normal characters.

        String queryTerm = "DX- zzzz";
    queryTerm = queryTerm.replaceAll("\\s", "AND");
    System.out.println(queryTerm);

    String queryTermWithNormalSpace = "DX- zzzz";
    queryTermWithNormalSpace = queryTermWithNormalSpace.replaceAll("\\s+", "AND");
    System.out.println(queryTermWithNormalSpace);

First queryTerm has Multi-Byte SPACE(0x3000) due to it doesn't find space and it doesn't do replace, but second string gives me output with replacement.

What would be the regular expression to do this?

1

There are 1 answers

0
Chetan Laddha On

Java 7:

queryTerm =
Pattern.compile("\\s",Pattern.UNICODE_CHARACTER_CLASS).match‌​er(queryTerm).replac‌​eAll("AND");