Skip to content Skip to sidebar Skip to footer

Preg_replace Equivalent In Java

How to convert this code into java code $response = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $response); I try this String jsonStr = 'Some Json string'; jsonStr.replaceAll('/[\x

Solution 1:

You have to escape the backslashes with another backslash like this:

jsonStr.replaceAll("[\\x00-\\x1F\\x80-\\xFF]", "");

Backslashes in strings introduce special characters in Java.

Post a Comment for "Preg_replace Equivalent In Java"