Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

  以前的做分隔符获取一个个字符串很是麻烦,其实JDK中的String 类已经很好的解决了这个问题。正则表达式确实是个好东西!

split

public String[] split(String regex)
Splits this string around matches of the given regular expression.

This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.

The string "boo:and:foo", for example, yields the following results with these expressions:

Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }

Parameters:
regex - the delimiting regular expression
Returns:
the array of strings computed by splitting this string around matches of the given regular expression
Throws:
PatternSyntaxException - if the regular expression's syntax is invalid
Since:
1.4
See Also:
Pattern
posted on 2005-09-29 16:23 java世界畅谈 阅读(1777) 评论(1)  编辑  收藏 所属分类: JAVA

评论

# re: String.class 的split方法 2006-01-07 17:41 山之上,国有殇
呵呵 地球人都知道  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: