Java 截取字符串的一些操作

   1: String str = "<table cellpadding=0 cellspacing=0 align=center>";
   2: str = str.substring(str.indexOf("ellpadding")); // str : ellpadding=0 cellspacing=0 align=center>
   3: str = str.substring(str.indexOf("ellspacing"), str.indexOf("enter")); // str : ellspacing=0 align=c
 
public String substring (int start, int end)

Since: API Level 1

Returns a string containing a subsequence of characters from this string. The returned string shares this string's backing array.

Parameters

start
the offset of the first character.

end
the offset one past the last character.

Returns
  • a new string containing the characters from start to end - 1
原文地址:https://www.cnblogs.com/xiaobo68688/p/2117814.html