I need to remove some characters from a string. I'm currently trying to remove '' (space) and '-' (hyphen). I tried two ways. Both of them work on Nexus 5X with Android N Beta. None of them work on Samsung Galaxy S 6 with Android M.
First approach:
String normalizedNumber = phoneNumber.replaceAll("[ -]", "");
Second approach:
Pattern pattern = Pattern.compile("[ -]");
String normalizedNumber = pattern.matcher(phoneNumber).replaceAll("");
How can such base classes give different results? What am I doing wrong?
Proof (screenshots of the debugger taken on different computers, why they differ from each other):
Here is the Nexus
Here is Samsung

source
share