星期三, 1月 11, 2012

[Java] 字串比對搜尋

Java字串搜尋的方法:

  String endpoint = "http://www.google.com.tw";
  System.out.println("string index of http:" + endpoint.indexOf("http://"));
  
  endpoint = "https://www.google.com.tw";
  System.out.println("string index of https:" + endpoint.indexOf("https://"));
  
  System.out.println("string re:" + endpoint.matches("^https://.*"));
  System.out.println("string contain:" + endpoint.contains("http"));

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails