21 lines
583 B
Java
21 lines
583 B
Java
//: strings/SplitDemo.java
|
|
// ©2015 MindView LLC: see Copyright.txt
|
|
import java.util.regex.*;
|
|
import java.util.*;
|
|
import static net.mindview.util.Print.*;
|
|
|
|
public class SplitDemo {
|
|
public static void main(String[] args) {
|
|
String input =
|
|
"This!!unusual use!!of exclamation!!points";
|
|
print(Arrays.toString(
|
|
Pattern.compile("!!").split(input)));
|
|
// Only do the first three:
|
|
print(Arrays.toString(
|
|
Pattern.compile("!!").split(input, 3)));
|
|
}
|
|
} /* Output:
|
|
[This, unusual use, of exclamation, points]
|
|
[This, unusual use, of exclamation!!points]
|
|
*///:~
|