fork download
  1. public class Main {
  2.  
  3. public static final String EXAMPLE_TEST = "This is my small example "
  4. + "string which I'm going to " + "use for pattern matching.";
  5.  
  6. public static final String EQUATION_TEST = "1+1=2";
  7.  
  8.  
  9. public static void main(String[] args) {
  10. System.out.println(EXAMPLE_TEST.matches("\\w.*"));
  11. String[] splitString = (EXAMPLE_TEST.split("\\s+"));
  12. System.out.println(splitString.length);// Should be 14
  13. for (String string : splitString) {
  14. System.out.println(string);
  15. }
  16. // Replace all whitespace with tabs
  17. System.out.println(EXAMPLE_TEST.replaceAll("\\s+", "\t"));
  18.  
  19.  
  20. String[] str = EQUATION_TEST.split("\\+|=");
  21. System.out.println("EQUATION_TEST.split="+str.length);// Should be 14
  22. for (String s : str)
  23. System.out.println(s);
  24. }
  25.  
  26.  
  27. }
Success #stdin #stdout 0.1s 212736KB
stdin
Standard input is empty
stdout
true
14
This
is
my
small
example
string
which
I'm
going
to
use
for
pattern
matching.
This	is	my	small	example	string	which	I'm	going	to	use	for	pattern	matching.
EQUATION_TEST.split=3
1
1
2