/* package whatever; // don't place package name! */ import java.util.*;import java.lang.*;import java.io.*; /* Name of the class has to be "Main" only if the class is public. */class Ideone{ public static void main (String[] args) throws java.lang.Exception { String teste = "espaco pontoevirgula;QUEBRA\ndelinha;"; String teste2 = "espaco pontoevirgula;QUEBRA\rdelinha;"; String regex = "((?<=;)|(?=;))|\\s"; String[] stringSeparada = teste.split(regex); String[] stringSeparada2 = teste2.split(regex); System.out.println(Arrays.toString(stringSeparada)); System.out.println(Arrays.toString(stringSeparada2)); }}
Standard input is empty
[espaco, pontoevirgula, ;, QUEBRA, delinha, ;] [espaco, pontoevirgula, ;, QUEBRA, delinha, ;]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!