Sunday, 17 November 2013

Split string using regular expression in java

How Split string using regular expression in java
 
public class RegEX {

      
       public static void main(String[] args) {
             String pattern = "([\\s+])";          
              String test="Have Nice Day ";
                 for(String token : test.split(pattern))
                     System.out.println(token);
                
       }

}

======================================
Result :
 
Have 
Nice
Day
======================================