In java, arrays and characters are sometimes decomposed and stored in arrays.
At that time, split is performed using the split method, but it is processed like this. (Variable name is appropriate)
private static final String SEPARATOR = "(\\s+?|\\.|,|;)";
String[] words = line.split(SEPARATOR);
These are regular expressions.
Specifically, it means "one or more spaces, periods, commas, or semicolons."
| Means one of the delimiters, and \. Is just a period (two backslashes are required for string notation).
Depending on the OS, \ becomes , or even though you type \ twice, only one is displayed on this screen.
It was learning (= ゜ ω ゜) no
Recommended Posts