JavaIntermediate#strings

How do you split a String and handle edge cases with delimiters that are regex special characters?

String.split() takes a regex, so delimiters like '.' or '|' must be escaped or use Pattern.quote() to be treated literally.

Example
"a.b.c".split("\\."); // ["a","b","c"]
"a|b|c".split(java.util.regex.Pattern.quote("|")); // ["a","b","c"]

Related Questions

1
JavaIntermediate#collections

What is the difference between Set implementations HashSet, LinkedHashSet, and TreeSet?

Open
2
JavaIntermediate#collections

What is the difference between Iterator and ListIterator?

Open
3
JavaIntermediate#collections

What is the difference between Deque and Queue?

Open