you can use regex
and replaceAll
method
String out = str.replaceAll("[^01]", "");
0
solved Remove all chars in java string, except ‘0’ and ‘1’ [closed]
you can use regex
and replaceAll
method
String out = str.replaceAll("[^01]", "");
0
solved Remove all chars in java string, except ‘0’ and ‘1’ [closed]