close
Regular Expression 是很好用的東西,Java 當然也有囉
這次為了將時間字串拆解而使用了 Pattern 類別
 
import java.util.regex.*; 
public class Splitter { 
   public static void main(String[] args) throws Exception {
      Pattern p = Pattern.compile("[:,/\\s]+"); 
                                   //這裡就用到了 Regular Expression
      String [] result = p.split("2007/10/17 15:02:30"); 
      for (int i = 0; i < result.length; i++) {
         System.out.println(result[i]);
      }
   }
}

arrow
arrow
    全站熱搜

    Kay 發表在 痞客邦 留言(1) 人氣()