...
Code Block | ||
---|---|---|
| ||
public class BadSplitter { private final String WORDS = "\b"; // IntendThe Intent was to split on word boundaries public String[] splitWords(String input){ Pattern p = Pattern.compile(WORDS); String[] input_array = p.split(input); return input_array; } } |
...
Code Block | ||
---|---|---|
| ||
public class GoodSplitter { private final String WORDS = "\\b"; // Will allowAllows splitting on word boundaries public String[] split(String input){ Pattern p = Pattern.compile(WORDS); String[] input_array = p.split(input); return input_array; } } |
...